I created the push push application after this tutorial: http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html
It works fine and dandy, and when I get a notification, I can open a website. However, can I combine the webview layout with this push notification application? I feel this should be possible because email notifications work this way.
Here is my code that processes the received notification:
private void handleData(Context context, Intent intent) {
String app_name = (String)context.getText(R.string.app_name);
String message = intent.getStringExtra("message");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(android.R.drawable.stat_notify_chat, app_name + ": " + message, 0);
PendingIntent pendingIntent = PendingIntent.getActivity(context, -1, new Intent(context, webviewactivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
notification.when = System.currentTimeMillis();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(context, app_name, message, pendingIntent);
notificationManager.notify(0, notification);
}
However, the HomeActivity associated with main.xml is just a button to register and unregister a device to receive notifications. I created another file, webviewactivity.xml under the layout:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
and I created the following activity, webviewactivity
public class BHWebView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bhwebview_activity);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.badgerherald.com");
}
}
- , , , -.