0
BroadcastReceiverから自分のデバイスにインストールされているapkを起動または開く必要があります。ここでANDROID - BroadcastReceiverから他のアプリケーションを起動する
はコードです:
パブリッククラスC2DMMessageReceiverはBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w("C2DM", "Message Receiver called");
if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
Log.w("C2DM", "Received message");
ComponentName toLaunch = new ComponentName("es.mypackage","es.mypackage.myapplication");
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
私のデバイスは、放送を受信するが、予想外の問題で失敗を拡張します。
他のapkを起動するコードは、アプリケーションの他の部分で正常に動作します。
ブロードキャストから他のアプリケーションを起動することはできますか?
ありがとうございました。
、ありがとう: テントの意図=新しいテント(); int.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setClass(context、MuestraTexto.class); context.startActivity(intent); これは問題なく動作し、アプリケーションのウィンドウを開きます。 インストールされた外部アプリケーションを起動しようとすると、最初に表示されたコードのみが失敗します。 ありがとう:) –