大佬教程收集整理的这篇文章主要介绍了从Android应用程序打开Whatsapp联系人列表,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
要打开whatsapp联系人列表:
btnChoose.setOnClickListener(new View.onClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setPackage("com.whatsapp"); try{ Toast.makeText(AddscheduleActivity.this,"going out activity",Toast.LENGTH_SHORT).show(); startActivityForResult(intent,1); Toast.makeText(AddscheduleActivity.this,"getTing In activity",Toast.LENGTH_SHORT).show(); } catch (Exception E) { Toast.makeText(AddscheduleActivity.this,"whatsapp not found",Toast.LENGTH_SHORT).show(); //no activity found to handle this intent means whatsapp is not installed } } });
要获得选择: –
@Override public void onActivityResult(int requestCode,int resultCode,Intent intent) { super.onActivityResult(requestCode,resultCode,intent); Toast.makeText(AddscheduleActivity.this,"Ok In",Toast.LENGTH_SHORT).show(); switch (requestCodE) { case 1: if(resultCode == RESULT_OK){ if(intent.hasExtra("contact")){ Toast.makeText(AddscheduleActivity.this,"Ok working",Toast.LENGTH_SHORT).show(); Uri uri = intent.getData(); //Query the content uri cursor cursor = getContentResolver().query(uri,null,null); cursor.moveToFirst(); // column index of the phone number int phoneIndex =cursor.getcolumnIndex(ContactsContract.CommonDataKinds.Phone.numbER); // column index of the contact name int nameIndex =cursor.getcolumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_Name); contactnumber = cursor.getString(phoneIndeX); name = cursor.getString(nameIndeX); } } break; default: break; } }
如果我没有选择任何联系并按回,那么在这种情况下他们不会崩溃
提前致谢.
以上是大佬教程为你收集整理的从Android应用程序打开Whatsapp联系人列表全部内容,希望文章能够帮你解决从Android应用程序打开Whatsapp联系人列表所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。