Question

I try to write sms manger, I want to access to my application from contact. I add following line into manifest

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.SENDTO" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>

and its work, but i want to get phonenumber, firstname , id and ... from this intent, how can get data?

Was it helpful?

Solution

In this case with this it will be enough:

//In the activity
Intent intent = getIntent();
String data = intent.getDataString();
//The result in data will be like sms:999%9999%9999 the % it's because is a URI
//If you want to get the phoneNumber directly
String phoneNumber = i.getData().getSchemeSpecificPart();//The result 999 9999 9999

So you can get from the phonenumber (999 9999 9999) the Contact name,Id, etc.Wich the answer you can see here:

Get Contact by Phone number on Android

When you try to use an intent filter the first thing is search in the documentation where/How, the creator send the information. In this case:

http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top