Skip to content Skip to sidebar Skip to footer

Android Read Phone State?

I'm trying to make app to READ PHONE STATE and when the phone state is changed to display Toast with the current state. But when I start it, the app stops unexpectedly. my class :

Solution 1:

I did not see <uses-permission android:name="android.permission.READ_PHONE_STATE" /> in your Manifest file.

It is required for your application to be able to read that state.

Solution 2:

<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.marakana"android:versionCode="1"android:versionName="1.0" >

    /* permission should be added like below*/
    <uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/><applicationandroid:icon="@drawable/icon"android:label="@string/app_name"android:theme="@android:style/Theme.Light" ><activityandroid:name=".TelephonyDemo"android:label="@string/app_name" ><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application><uses-sdkandroid:minSdkVersion="7" /></manifest>

Solution 3:

Your application knows PHONE STATE thanks an Intent that is Broadcasted by the Telephony Service notifying to application about PHONE STATE changes. You may need Guide line to create your application

Post a Comment for "Android Read Phone State?"