public class GcmIntentService extends IntentService {
....
public GcmIntentService() {
super("GcmIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Context context = getApplicationContext();
Intent in = new Intent(context, MainActivity.class);// change the context and activity name.
in.putExtras(intent.getExtras());
in.putExtra("url","http://www.daum.net");
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(in); // change the context name.
...
Log.i(TAG, "Received: " + extras.toString());
}
}
// Release the wake lock provided by the WakefulBroadcastReceiver.
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
...
}
GCM 수신 후 MainActivity.class에 있는 webview의 URL을 원하는 주소로 변경하려고 합니다.
Context context = getApplicationContext();
Intent in = new Intent(context, MainActivity.class);// change the context and activity name.
in.putExtras(intent.getExtras());
in.putExtra("url","http://www.daum.net");
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(in); // change the context name.
이렇게 하려고 하니 기존의 MainActivity.class에 접근하는 것이 아니라 새로운 MainActivity.class가 뜨게 되네요. 기존의 MainActivity.class에 접근해서 webview의 URL을 제어할 수는 없을까요?