In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how Android uses ContentProvider to view system SMS function". In daily operation, I believe many people have doubts about how Android uses ContentProvider to view system SMS function. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "how to view system SMS function with Android using ContentProvider". Next, please follow the editor to study!
Activity_main.xml
Sms.java
Public class Sms {private int id; private String address; private String body; public Sms (int id, String address, String body) {this.id = id; this.address = address; this.body = body;} public int getId () {return id;} public void setId (int id) {this.id = id;} public String getAddress () {return address } public void setAddress (String address) {this.address = address;} public String getBody () {return body;} public void setBody (String body) {this.body = body;}}
MainActivity.java
Public class MainActivity extends AppCompatActivity {private TextView tv_show; private Button bt_show; private List list=new ArrayList (); private String text= ""; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); tv_show=findViewById (R.id.tv_show); bt_show=findViewById (R.id.bt_show) } public void show (View view) {ActivityCompat.requestPermissions (MainActivity.this,new String [] {Manifest.permission.READ_SMS}, 1);} public void getSms () {Uri uri= Uri.parse ("content://sms/"); ContentResolver contentResolver=getContentResolver () Cursor cursor = contentResolver.query (uri, new String [] {"_ id", "address", "body"}, null, null, null); if (cursorsor.getCount () > 0) {if (listings empty null) {list.clear ();} text= "" While (cursor.moveToNext ()) {int id=cursor.getInt (0); String name=cursor.getString (1); String body=cursor.getString (2); Sms sms=new Sms (id,name,body); list.add (sms);} for
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.