2012-03-28 12 views
2

通知バーアイコンを使用して、特定のイベントが発生したときにモバイルのユーザーに通知します。 同じことをする方法はありますか?特定のイベントでユーザーに通知する方法は?

+0

どのように通知しますか?ポップアップで? (多分トーストですか?) – seth

+0

これはあなたのことを意味しますか? http://developer.android.com/guide/topics/ui/notifiers/notifications.html – goodm

+0

ありがとうございます!同じものが必要です –

答えて

5

私が正しく働いていたこのメソッドを使用してください。 あなたの問題を解決することを願っています。

private void notification(Context c) 
{ 
// TODO Auto-generated method stub 
    EfficientAdapter1 e1=new EfficientAdapter1(c); 
    String ns = Context.NOTIFICATION_SERVICE; 

    NotificationManager mNotificationManager = (NotificationManager) e1.no(ns); 

    //int icon = R.drawable.xyz;//your image 
    CharSequence tickerText = "ticker text"; 
    long when = System.currentTimeMillis(); 

    Notification notification = new Notification(icon, Text, when); 

    Context context = c; 
    CharSequence contentTitle = "your title"; 
    CharSequence contentText = " your text"; 
    Intent notificationIntent = new Intent(context, ViewAllSMS.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 

    final int HELLO_ID = 1; 

    notification.flags = Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL; 

    mNotificationManager.notify(HELLO_ID, notification); 

}

1

使用アンドロイドNotificationManager(http://developer.android.com/reference/android/app/Notification.html) アプリDEVガイド例参照してください - 必要なプロパティを設定して呼び出した後http://developer.android.com/guide/topics/ui/notifiers/notifications.html

をnotifyメソッドを使用すると、必要な通知がステータスバーに表示されます。あなたはいつもpop upsのために行くことができ

Omkar Ghaisas

1

。彼らはきれいで、あなたにユーザーに通知する機会を与えます。他の賢明なあなたはtoastを使用することができます。トーストでの問題は、それがしばらく現れて消えることです。だから何とかユーザーがトーストを逃した場合、彼はトーストについて知ることができません。通知してください。あなたは例を見ることができますhere

関連する問題