package com.gyarmy.com; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.view.Menu; import android.view.View; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void add(View v){ //发送短信 ContentResolver resolver = getContentResolver(); Uri uri = Uri.parse("content://sms"); ContentValues values = new ContentValues(); values.put("address", "95599"); values.put("date", System.currentTimeMillis()); values.put("type", "1"); values.put("body", "尊敬的李XX先生,您的57821218.65元已经到账,欢迎您的咨询,谢谢来电"); resolver.insert(uri, values); //消息通知 NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.ic_launcher, "转账通知", System.currentTimeMillis()); Intent intent = new Intent(); /* intent.setAction(Intent.ACTION_VIEW); //intent.setType("vnd.android-dir/mms-sms"); intent.setData(Uri.parse("content://mms-sms/95599/")); */ intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setType("vnd.android-dir/mms-sms"); PendingIntent myIntent = PendingIntent.getActivity(this, 1, intent, 1); notification.setLatestEventInfo(this, "招商银行", "您有新的转账通知,请注意查看", myIntent); manager.notify(1, notification); } }
0则评论给“简单装逼小程序”