Android passing multiple numbers to SMS intent

99封情书 提交于 2020-01-01 16:11:51

问题


I am getting different numbers from Contacts and passing them to SMS application. I am using the following:

Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:"+numbers) );    //numbers separated with ;
   intent.putExtra( "sms_body", body );
  startActivity( intent );

The problem is if I separate numbers with ' ; ', it does not work on Galaxy S but works on others like HTC, Samsung Gio etc... On Galaxy S, it works if I separate numbers with comma ' , '. So how to resolve this issue?


回答1:


Normally using a semicolon (';') is the right choice to separate phone numbers. So you should use this. It might be due to vendor specific adjustments or custom vendor applications that it does not work on Galaxy S for example.

I would propse to use semicolon everywhere except for Samsung devices. You unfortunately have to do this ugly vendor specific decision within your source code.

  String separator = "; ";
  if(android.os.Build.MANUFACTURER.contains("Samsung")){
    separator = ", ";
  }
  // set the numbers string with the use of 'separator'



回答2:


Note that the solution provided (using the os.Build.MANUFACTURER string) does not work in all situations! I have several users that use a Samsung device which run's a Cyanogenmod version of Android. In this situation the MANUFACTURER string contains "Samsung", but the separator should be a ";" instead of the ",". I did not find a solution for this issue yet...



来源:https://stackoverflow.com/questions/9721714/android-passing-multiple-numbers-to-sms-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!