文件名称:接收广播的最高优先级
文件大小:248KB
文件格式:ZIP
更新时间:2018-11-18 04:03:05
Android,广播
@SuppressLint("NewApi") public class MainActivity extends Activity { SmsReceiver myReceiver; Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn = (Button) findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { test(); } }); } public void test(){ Cursor cursor = null; String defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(this); Intent intent = new Intent(Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Sms.Intents.EXTRA_PACKAGE_NAME, this.getPackageName()); startActivity(intent); try { cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "_id", "address", "read" }, "read = ? ", new String[] {"0" }, "date desc"); if (cursor != null) { ContentValues values = new ContentValues(); values.put("read", "1"); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { Log.v("cky", "" + cursor.getInt(cursor.getColumnIndex("_id")) + " , " + cursor.getString(cursor.getColumnIndex("address"))); int res = getContentResolver().update(Uri.parse("content://sms/inbox"), values, "_id=?", new String[] { "" + cursor.getInt(cursor.getColumnIndex("_id")) }); Log.i("cky","geng xin = "+res); } } intent = new Intent(Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Sms.Intents.EXTRA_PACKAGE_NAME, defaultSmsApp); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); cursor = null; } } } }
【文件预览】:
AndroidTest
----.project(847B)
----project.properties(563B)
----src()
--------com()
----AndroidManifest.xml(3KB)
----res()
--------drawable-ldpi()
--------drawable-hdpi()
--------values-v11()
--------menu()
--------drawable-mdpi()
--------layout()
--------drawable-xxhdpi()
--------drawable-xhdpi()
--------values-w820dp()
--------values()
--------values-v14()
----.settings()
--------org.eclipse.jdt.core.prefs(177B)
----assets()
----gen()
--------com()
----.classpath(475B)
----proguard-project.txt(781B)
----ic_launcher-web.png(50KB)
----bin()
--------resources.ap_(41KB)
--------classes()
--------AndroidTest.apk(47KB)
--------AndroidManifest.xml(3KB)
--------dexedLibs()
--------res()
--------classes.dex(9KB)