I have a widget that contains 4 buttons to show 4 stock prices, each of which will launch in the same type of activity Quote.class to show details. In onUpdate (), it will configure pendingIntent with additional functions with a stock symbol. After I press the A button, it will go to the citation activity, which shows the stock A. Then I press the BACK button on the desktop, the onDestroy () activity request is called, and when I press the B button, the B indicator will be displayed correctly. However, when I press the HOME button after it shows the stock, the Quote activity only calls onStop without calling onDestroy (), and then when I press the B button, it is called onStart () and shows the same instance that shows stock A.
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.etappwidget); setQuoteIntent(context, views, R.id.view1, "BAC", 1); setQuoteIntent(context, views, R.id.view2, "C", 2); setQuoteIntent(context, views, R.id.view3, "GOOG", 3); setQuoteIntent(context, views, R.id.view4, "AAPL", 4); private static void setQuoteIntent(Context context, RemoteViews views, int viewId, String symbol, int requestCode) { Intent i = new Intent(context, Quote.class); i.putExtra("SYMBOL", symbol); i.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); PendingIntent pi = PendingIntent.getActivity(context, requestCode, i, PendingIntent.FLAG_UPDATE_CURRENT); views.setOnClickPendingIntent(viewId, pi);
}
Initially, I thought that adding a flag to Intent should solve this problem. But I tried i.setFlags (Intent.FLAG_ACTIVITY_MULTIPLE_TASK or FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_NO_HISTORY), none of them have any meaning.
So are there any ways to make it work? How to remove history stack from HOME button? How can I call onCreate in Quote Quote and get new additions when I press button B? Any help is appreciated. thanks