10
我似乎有我的代碼有問題。 我已經創建了一個測試活動,只是爲了看看有什麼問題,我仍然不能。我的代碼有什麼問題 - 通知 - 沒有聲音沒有震動
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String extra = "test";
NotificationManager myNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this, test.class);
Notification notification = new Notification(R.drawable.icon,
extra,
System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(getApplicationContext(), "title", "text", pendingIntent);
notification.flags |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.DEFAULT_LIGHTS;
notification.flags |= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.FLAG_INSISTENT;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotificationManager.notify(33, notification);
}
}
當通知彈出時,我聽不到聲音和/或震動。
我看了一下手機的設置,他們沒問題,沒有默認的默認聲音。