2011-04-28 2 views
1

Android에서 알림을 만들려고합니다. 아이콘이 표시되고 텍스트가 흔들립니다. 또한 클릭하면 Intent가 호출되지 않습니다. (나는 웹 브라우저를 가져와야하는 테스트 의도가있다.) 텍스트가 사라지는 이유를 알아낼 수 없으며 sttus 바를 클릭하면 브라우저가 나타나지 않습니다. 코드알림을 생성하는 방법을 알아 내려고하는 android

public class Welcome extends Activity 
{ 
    private NotificationManager mNotificationManager; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     mNotificationManager = (NotificationManager) 
      getSystemService(NOTIFICATION_SERVICE); 
     Notification notifyDetails = new Notification(
       R.drawable.icon, "Click Me!", System.currentTimeMillis()); 

     Context context = getApplicationContext(); 
     CharSequence contentTitle = "Notification Details..."; 
     CharSequence contentText = "Ted"; 
     Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW, 
       Uri.parse("http://www.android.com")); 

     PendingIntent intent = PendingIntent.getActivity(this, 0, notifyIntent, 
       android.content.Intent.FLAG_ACTIVITY_NEW_TASK); 
     notifyDetails.setLatestEventInfo(context, contentTitle, 
       contentText, intent); 
     mNotificationManager.notify(1, notifyDetails); 
    } 
} 

테드

답변

0

당신은 초기화 시도 할 수 귀하의

new Intent(packageContext:Context, cls:Class<?>) 

생성자 notifyIntent.

new Intent(action:String, uri:Uri)의 작동 방식을 보려면 overview of the Intent class을 참조하십시오.

관련 문제