Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 通知意图活动_Android_Android Intent_Android Activity_Notifications - Fatal编程技术网

Android 通知意图活动

Android 通知意图活动,android,android-intent,android-activity,notifications,Android,Android Intent,Android Activity,Notifications,我有一些关于通知意图的问题。我有两项活动(A和B)。活动A是我的应用程序的主要活动。用户将经历的第一个活动。至于活动B,则是用户通过单击活动a上的按钮进行输入 问题是,当我点击我的通知时,它会将我引导到活动B。然后在返回时将我引导回活动A。但是,当我关闭应用程序并通过多任务选项将其打开时,它会在活动B中恢复我的应用程序。我希望应用程序在关闭后重新启动活动A 订单应该是 活动A-->活动B. 单击时通知->活动B(按下时)->活动A-->关闭。 重新打开应用程序/使用多任务功能打开-->活动A 请

我有一些关于通知意图的问题。我有两项活动(A和B)。活动A是我的应用程序的主要活动。用户将经历的第一个活动。至于活动B,则是用户通过单击活动a上的按钮进行输入

问题是,当我点击我的通知时,它会将我引导到活动B。然后在返回时将我引导回活动A。但是,当我关闭应用程序并通过多任务选项将其打开时,它会在活动B中恢复我的应用程序。我希望应用程序在关闭后重新启动活动A

订单应该是

活动A-->活动B.

单击时通知->活动B(按下时)->活动A-->关闭。

重新打开应用程序/使用多任务功能打开-->活动A

请让我知道,如果有任何其他信息,我可以提供一个适当的理解我的问题

GCM_.class

    Notification note = new Notification(icon, msgTopic ,System.currentTimeMillis());
    Intent i=new Intent(this, Activity_B.class);
    i.putExtra("topicId", topicId);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
    Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pi=PendingIntent.getActivity(this, CommunitiesappConstant.NOTIFICATION_ID, i,  PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
    note.setLatestEventInfo(this, topicName ,msgInfo+message, pi);
    note.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
    note.ledARGB |= 0xff0000ff;
    note.ledOffMS |= 1000;
    note.ledOnMS |= 300;


    mgr.notify(CommunitiesappConstant.NOTIFICATION_ID, note);
活动B.课堂

@Override
public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_b);
    Bundle bundle = getIntent().getExtras();
    topicId = bundle.getString("topicId");

}

@Override
public void onBackPressed() {
    super.onBackPressed();
    Log.e(TAG,  "onBackPressed");
    Intent i = new Intent(Activity_B.this, Activity_A.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
    finish();
}

通知是一条可以在应用程序的正常UI之外显示给用户的消息。这是使用通知的完美代码

NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.notification_icon)
        .setContentTitle("My notification")
        .setContentText("Hello World!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, ResultActivity.class);

// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(ResultActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
        stackBuilder.getPendingIntent(
            0,
            PendingIntent.FLAG_UPDATE_CURRENT
        );
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(mId, mBuilder.build());

要像这样在背面按()


如何获取此中间列表。获取(长度-1)?中间列表。获取(长度-1)只不过是您的第一个活动。请尝试。我需要将此代码放置在何处?我想在我的网站上发布任何新帖子时向用户显示通知。我已经使用WebView创建了一个android应用程序
Activity current = getLocalActivityManager().getActivity(mIdList.get(length-1));
        current.finish()