Correct intent flags to use
Within my Main Activity that loads a Webview, depending on where it was
launched from determines the url to load.
Bundle extras = getIntent().getExtras();
if (extras != null) {
String theurl = getIntent().getExtras().getString("url");
webView.loadUrl(theurl);
} else {
webView.loadUrl("http://go-rental.com/app");
}
If the application is a fresh instance and loaded from the home screen it
loads the default url.
If the application is not running and i click a notification that was sent
through google cloud messaging the application loads a custom url.
This functions as expected.
My problem lies when the application is already running in the background,
when i click a notification it will bring the app to the front but wont
load the new url, it stays at the default.
I'm not too sure with the Flags, i did have this problem before and it was
a certain combination of flags that fixed it.
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra("url", url);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
int requestID = (int) System.currentTimeMillis();
PendingIntent intent = PendingIntent.getActivity(context, requestID,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT |
PendingIntent.FLAG_ONE_SHOT);
Help would be greatly appreciated.
No comments:
Post a Comment