2011-04-28 8 views
1

私はアンドロイドで通知を作成しようとしています。アイコンが表示され、テキストがぼやけます。また、それをクリックすると、インテントは呼び出されません。 (私はウェブブラウザを立ち上げるべきテストの意図を持っている)。 テキストが消える理由を理解できず、sttusバーをクリックするとブラウザが表示されません。 コードアンドロイドが通知を作成する方法を理解しようとしています

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をご覧ください。

関連する問題