0

I want to add a feature to my app that when I touch the number in a message, the user can decide to send the number to my app or Android Dialer.

For example my friend send me a code and i want to use this code for special ussd code that my app run it.

I think I have to use implicit intent but I don't know how?

Thanks

Mehdi
  • 1,260
  • 2
  • 16
  • 36

2 Answers2

1

I have quoted the below links

-intent filter

-Intents implicit\explicit

Implicit intents specify the action which should be performed and optionally data which provides data for the action.

For example the following tells the Android system to view a webpage. All installed web browsers should be registered to the corresponding intent data via an intent filter.

Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.vogella.com")); startActivity(i); 

If an Explicit intent is send to the Android system, it searches for all components which are registered for the specific action and the fitting data type.

If only one component is found, Android starts this component directly. If several components are identifier by the Android system, the user will get an selection dialog and can decide which component should be used for the intent.


How to use

You can register your own components via Intent filters. If a component does not define one, it can only be called by explicit intent.


Register an activity as Browser

<activity android:name=".BrowserActivitiy" 
          android:label="@string/app_name">
  <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:scheme="http"/> 
  </intent-filter>
</activity>

UPDATES

A code sample for mimeType

<activity android:name="ShareActivity">
<intent-filter>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
    <data android:mimeType="image/*"/>
</intent-filter>

Srinath Ganesh
  • 2,496
  • 2
  • 30
  • 60
  • Thank you @Srinath .Do you know I have to choose what kind of action?(If it is not action.SEND) and what I have to set for data scheme or mimtype? – Mehdi Sep 08 '13 at 13:55
0

I assume you are talking about a number in a SMS that you received. On clicking that number you want the user to get an option to either dial or use your app.

If yes then you need to include intent filter in your manifest file for launcher activity.

Maulik Sheth
  • 584
  • 3
  • 10
  • Yes, You exactly understand what I said, but i don't know how to do that? what action I have to use, what is the category? I just guess that I have set the mimType number. – Mehdi Sep 08 '13 at 13:40
  • read this and see if you get the answer or any other information. http://developer.android.com/guide/components/intents-filters.html and this http://developer.android.com/training/basics/intents/index.html – Maulik Sheth Sep 08 '13 at 14:00