android 常规

 

/*

* 常规

*/

 

//***发送 SMS

 

// AndroidManifest.xml must have the following permission:

// <uses-permission android:name="android.permission.SEND_SMS"/>

SmsManager m = SmsManager.getDefault();

String destinationNumber ="0123456789";  

String text = "Hello, MOTO!";  

m.sendTextMessage(destinationNumber, null, text, null, null);

 

//***显示 Toast

 

Toast.makeText(this, "Put your message here", Toast.LENGTH_SHORT).show();

 

//***状态栏通知

 

int notificationID = 10;

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// Create the notification

Notification notification = new Notification(R.drawable.yourIconId, "Put your notification text here", System.currentTimeMillis());

// Create the notification expanded message

// When the user clicks on it, it opens your activity

Intent intent = new Intent(this, YourActivityName.class);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

notification.setLatestEventInfo(this, "Put your title here", "Put your text here", pendingIntent);

// Show notification

notificationManager.notify(notificationID, notification);

 

//***在给定时间内振动手机

 

// AndroidManifest.xml must have the following permission:

// <uses-permission android:name="android.permission.VIBRATE"/>

// Vibrate for 1000 miliseconds

Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); 

vibrator.vibrate(1000);

 

//***在开/关模式后振动手机

 

// AndroidManifest.xml must have the following permission:

//<uses-permission android:name="android.permission.VIBRATE"/>

// Vibrate in a Pattern with 0ms off(start immediately), 200ms on, 100ms off, 100ms on, 500ms off, 500ms on,

// repeating the pattern starting from index 4 - 100ms on. 

// Note that you'll have to call vibrator.cancel() in order to stop vibrator.

// Change second parameter to -1 if you want play the pattern only once. 

Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

vibrator.vibrate(new long[] {0, 200, 100, 100, 500, 500}, 4);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值