How to use com.android.internal.telephony.Phone - android

I'm new developer on android. What I needed in purpose to use com.android.internal.telephony? Downloading ? Special permissions ?

You have to add the following lines in your Manifest, inside of the application tag:
<uses-feature android:name="android.hardware.telephony">
</uses-feature>
Also particular features require special Permissions, for example sending and receiving sms requires:
<uses-permission
android:name="android.permission.RECEIVE_SMS" >
</uses-permission>
<uses-permission
android:name="android.permission.SEND_SMS" >
</uses-permission>

Related

XIAOMI MI4W with android 6.0.1 not set SMS_READ permission by programmatically

I'm setting up permission in Manifest file
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS" />
But unfortunatly I can't get SMS permissin, after I setted up application, I should go to security property of smartphone and set it by myself. What the reason, is it reason of MI restrictions or I must set somthing else in 6 version of Android. This worked on previos version on this smartphone.
From Android marshmallow you need to give run time permission.
Add below given code in your launch activity onCreate() method.
String permission = Manifest.permission.READ_SMS;
if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){
permissionList.add(permission);
if (!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
requestPermissions(new String[]{permission}), SMS_PERMISSION);
}
}

Android Uses-Feature VS. Uses-Permision Optimization

I have the following permissions explicitly requested in my manifest.
I would like to optimize store visibility by switching as many as possible of them to implicit 'uses-feature' declarations. I will also handle this additionally in code checking for features before I access them.
Internet access is the only thing that's truly required for my app, other features I can enable/disable conditionally based on hasFeatures().
Question:
Which of these permissions can I change?
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<permission android:name="com.appName.supportmapfragment.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.appName.supportmapfragment.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Set required to 'false' if your app doesn't require something to run:
To control filtering, always explicitly declare hardware features in
elements, rather than relying on Google Play to
"discover" the requirements in elements. Then, if
you want to disable filtering for a particular feature, you can add a
android:required="false" attribute to the declaration.
http://developer.android.com/guide/topics/manifest/uses-permission-element.html (in the right-hand sidebar)
The documentation has this example:
<uses-feature android:name="android.hardware.camera" android:required="false" />

Get neighboring cell in Android returns null

I'm trying to get the neighbouring cell info in Android but the function getNeighboringCellInfo() always return null.
I used the following code :
protected void getCellInfo() {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
if (neighborCells == null) {
OutUtils.debug("no neighbor cells");
} else {
...
}
}
The context variable is from a Service class.
My AndroidManifest.xml permission
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I tried with and without enabling the "Use 2G networks" option in Android.
Any idea ? Thanks
If you can run logcat, try running logcat -b radio. If you are lucky, the RIL code will be spitting out debug messages, showing the actual request to the modem for the neighboring cell info. It could well be that the modem is just returning an empty list. If this is the case, it has nothing to do with permissions, and there is not much you can to fix it.
The cellid implementation varies from mobile device to mobile device since these features are considered to be optional. for example:
Samsung (all devices): getNeigbouringCells () is not supported at all and always returns an empty list.
according to this: http://wiki.opencellid.org/wiki/Android_library
and this: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=24306
I think, maybe you haven't set all necessary permissions in Manifest. look here Null Issue with NeighboringCellInfo, CID and LAC
If you think you have them, put the manifest in the question, too, please.

Android - Simple permissions - Why don't I need this permission?

I'm currently working images using
mBitmap = BitmapFactory.decodeFile(filePath);
ExifInterface exif = new ExifInterface(filePath);
My permissions are:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I thought I needed a read storage permission to get the files from the gallery. Why can I access files from my Gallery without this permission?
If it helps, I'm using the ACTION_SEND intent filter to start the activity via a "Share" dialog.
Edit: Just to clarify, my application works perfectly. I thought I would need a special permission to read files from the SD card (such as images). Is this not the case?
this is
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Android Development: How to request permissions?

I was just wondering how to request permissions when creating an android application. I am a beginner, so please explain in simple terms :D.
So I want to make it so that my app can vibrate the phone at certain times, and the permission is called "android.permission.VIBRATE." But how do I request this? I do it in the Android Manifest file right?
Thanks for all help!
You're definately right. You need to put it in the AndroidManifest.XML
If you're using eclipse you can do it quite easily and without XML by opening up AndroidManifext.xml and use the Permissions tab at the bottom and press the "Add" button and selecting "Uses Permission" Then just select vibrate from the dropdown list.
If you want to do it in XML code you can add it before the application tag, like so:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:name="Application" >
(the rest of your manifest continues from here)
Also, please accept answers if you found them useful. With a 0% acceptance rate, people won't want to answer your questions.

Categories

Resources