package jp.mixi.assignment.messagingandnotification; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.os.Bundle; import android.support.v4.app.NotificationCompat; import android.support.v7.app.ActionBarActivity; /** * Created by suino on 2015/02/26. */ public class NotificationActivity1 extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notification1); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); Notification notification = builder .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("通知テスト") .setContentText("通知の詳細テスト") .setTicker("通知ティッカーテスト") .setVibrate(new long[]{3000}) // 3秒間バイブレーションが作動 .build(); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(0, notification); } }