简体   繁体   中英

android widget starts an new activity

I can bring up an activity by clicking on a view in a widget using PendingIntent
If an activity is not yet started, android will create a new and call onCreate() , i can retrieve getExtra() from the widget

However if the activity is already started and in the top of the stack , the target activity is just brought to the top to display without running any code

I cannot use android:launchMode="SingleTop" to call onNewIntent (Intent intent) , but I need "multiple" activity from other part of the app

I just want the click event of the widget view just start a new instance of activity as the behaviour of android:launchMode="standard" so that I can decide what should be done based on getExtra()

any idea ? thank you

sending broadcast when you widget clicked, will help you to the problem of starting activity. you can use the getBroadcast() method of PendingIntent.

public static PendingIntent getBroadcast (Context context, int requestCode, Intent intent, int flags)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM