2010-12-23 3 views
1

알림 메시지를 통해 선택할 수있는 전체 화면으로 전환하려는 Tabview (작은 화면의 1/3 정도)에서 전환하려고했습니다.Android 알림 메시지 (전환하지 않음) 활동에서 전환합니다.

지금까지 너무도 좋았습니다. 많은 하우투의 모든 지시 사항을 따르며 모든 것이 매력처럼 작동했습니다. (즉, sdk 에뮬레이터에 있음)

이제 실제 Android 전화로 앱을 전송 했으므로 알림을 통해 더 이상 화면을 전환하지 않습니다. 그것은 항상 MainActivity를 엽니 다.

private void DroiDCNotification(int NotificationID, CharSequence tickerText, CharSequence contentTitle, CharSequence contentText) { 
    //throw new UnsupportedOperationException("Not yet implemented"); 
    String ns = Context.NOTIFICATION_SERVICE; 
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); 
    int icon = R.drawable.droidc_icon;  // icon from resources 
    long when = System.currentTimeMillis();   // notification time 
    Context context = getApplicationContext();  // application Context 
    Intent notificationIntent = new Intent(this, MainActivity.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 
    // the next two lines initialize the Notification, using the configurations above 
    Notification notification = new Notification(icon, tickerText, when); 
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
    mNotificationManager.notify(NotificationID, notification); 
} 

특정 활동이 호출하는 알림을 지정된 활동을 열도록하려면 어떻게해야합니까?

답변

1

알림 메시지를 통해 선택할 수있는 전체 화면으로 전환하려는 Tabview (작은 화면의 1/3 정도)에서 전환하려고했습니다.

왜 이것이 좋은 생각이라고 생각하지 않습니다. 알림은이 역할을 위해 설계되지 않았습니다. 옵션 메뉴를 사용하십시오.

특정 활동이 호출하는 알림을 지정된 활동을 열도록하려면 어떻게해야합니까?

PendingIntent을 실행할 예정입니다. PendingIntentIntent (MainActivity.class)을 포함합니다. MainActivity.class을 사용하려면 MyActivity.class을 원하는 클래스로 변경하십시오.

+0

감사합니다,이 twolines을 사용합니다. – Johan

1

안녕하세요 그냥 년 활동에 실제로 매우 논리를 소리

Intent notificationIntent = new Intent(context, SamplePushActivity.class); 
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);