我想分享一个特定的活动(Android)

时间:2015-11-13 08:56:39

标签: android

我正在开发一个我希望分享特定活动的应用。我以前通过Google Play分享了该应用;但在这种情况下,我想分享,当您直接发送链接时,打开您共享的屏幕;如果您没有安装该应用,请转到Google Play页面。有谁可以帮助我吗? 我的代码:

清单:

<activity
    android:name=".FichaLibro"
    android:label="@string/strTitleActivityFichaLibro"
    android:screenOrientation="portrait">

            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="http"
                    android:host="www.example.com"
                    android:pathPrefix="/gizmos" />

            </intent-filter>

</activity>

JAVA(FichaLibro.java):

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_ficha_libro);

        Intent intent = getIntent();
        idLibro = intent.getStringExtra("idLibro");
        usuario = (Usuario) intent.getSerializableExtra("usuario");

        altaElementos();


        Intent intentUri = getIntent();
        String action = intentUri.getAction();
        String type = intentUri.getType();
        Uri data = intentUri.getData();
        Uri data2 = (Uri)intentUri.getParcelableExtra(Intent.EXTRA_STREAM);


        Log.v("ACTION", action+"");
        Log.v("TYPE", type+"");
        Log.v("URI", data+"");
        Log.v("URI2", data2+"");

ALL LOG RETURN NULL。 WHY ?????

如果我创建一个具有单个活动的应用(MainActivity)并包含在清单

<intent-filter>
    <action android: name = "android.intent.action.VIEW" />
    <category android: name = "android.intent.category.DEFAULT" />
    <category android: name = "android.intent.category.BROWSABLE" />

    <data android: scheme = "http"
          android: host = "www.example.com"
          android: Pathprefix = "/ gizmos" />

</ intent-filter>

应该得到行动和类别数据的价值吧?

Intent intentUri = getIntent();
String action = intentUri.getAction();
String type = intentUri.getType();
Uri data = intentUri.getData();
Uri data2 = (Uri)intentUri.getParcelableExtra(Intent.EXTRA_STREAM);

或者我应该做别的事情吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

这只是我的猜测。 也许像https://play.google.com/store/apps/details?id= yourPageckageName / activtyC

这样的链接

// <intent-filter>

// <action android:name="android.intent.action.MAIN" />

// `<category android:name="android.intent.category.LAUNCHER" />`

     // `</intent-filter>`

也许应该删除代码。

<intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="httpa" />
        </intent-filter>

    </activity>

在活动中:

 onCreate(){
//read extra
//skip to activityC
}

enter image description here