0

AとBの2つのアプリがあります
。BをAで呼び出したいです。A
のコードは次のとおりです。

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.example.bapp","com.example.bapp.BActivity"));
intent.putExtra ("test2abc", "abctest2");
startActivity(intent);

そして、マニフェストのBのインテントフィルターは次のとおりです。

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

ただし、Bが開いている間は、Bを起動する前にBを閉じます。
*.txtファイルを開くための以下のコードを見つけました。これにより、2つのtxtリーダーアプリが同時に開きます。

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), mimetype);
startActivity(inte

nt);

どうすれば到着できますか?

4

2 に答える 2

4

ちょっと私はこのコードスニペットを見つけましたAndroid上の別のアプリケーションからアプリケーションを起動します。これはあなたのために動作しますあなたが起動したいアプリケーションのアドレスを設定します

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
于 2013-01-10T06:26:32.183 に答える
2

ランチャーアクティビティを定義するときに、android: launchMode = "singleInstance"android:finishOnTaskLaunch="true"を試してみることをお勧めします 。

   <activity
        android:name="com.example.test.sampleMediaPlayer"
        android:label="@string/app_name"
        android:launchMode="singleInstance"
        android:finishOnTaskLaunch="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

アクティビティAの場合。

于 2013-01-10T13:05:29.413 に答える