android-7.0-nougat

TelephonyManager's PhoneStateListener is not called on Nougat

江枫思渺然 提交于 2020-01-23 11:10:48
问题 I have made a sample app and the PhoneStateListener TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); //TelephonyManager object telephony.listen(new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { Log.i("brian", "call state = " + state + " incoming number " + incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: break; case TelephonyManager.CALL_STATE_RINGING: break; case

TelephonyManager's PhoneStateListener is not called on Nougat

空扰寡人 提交于 2020-01-23 11:09:04
问题 I have made a sample app and the PhoneStateListener TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); //TelephonyManager object telephony.listen(new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { Log.i("brian", "call state = " + state + " incoming number " + incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: break; case TelephonyManager.CALL_STATE_RINGING: break; case

android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

别等时光非礼了梦想. 提交于 2020-01-16 16:25:59
问题 The app is crashing when I'm trying to open a file. It works below Android Nougat, but on Android Nougat it crashes. It only crashes when I try to open a file from the SD card, not from the system partition. Some permission problem? Sample code: File file = new File("/storage/emulated/0/test.txt"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "text/*"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); // Crashes on this line

How to set audio as ringtone programmatically above Android N

流过昼夜 提交于 2020-01-13 03:48:06
问题 In the past, we could use code below to set an audio file as ringtone: ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, musicFile.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "my music"); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); // true for notification sound

How to get current location in android 7?

浪尽此生 提交于 2020-01-11 11:30:13
问题 I'm trying to get current location in android and its OK when i'm using on android M or lower, But when i run my application on android N, location is null and when i want get latitude from it will returns 0. here is my code try { if (!isGPSEnabled && !isNetworkEnabled) { } else { this.canGetLocation = true; if (isNetworkEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); Log.d("Network", "Network");

The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25; please update

China☆狼群 提交于 2020-01-11 08:16:48
问题 I am getting this error on the latest version of Android Studio and while I have installed both Android SDK Platform API 25 and Android SDK Build-Tools 25. 回答1: I had a similar problem. Updating Android Studio to version 2.2.2 (latest at the time of this writing) and Gradle version to 2.2.2 (latest at the time of this writing) in project_name/build.gradle file fixed this issue. For reference, this is my config in project_name/app/build.gradle file: minSdkVersion = 19 targetSdkVersion = 25

Android Nougat PhoneStateListener is not triggered

旧城冷巷雨未停 提交于 2020-01-11 05:26:07
问题 In Android (target 25) I have a background service and in onCreate function I have initialized a phone state listener. It works fine on Android versions that are before Nougat but in Nougat it doesn't work, even though the permissions are granted. public class Service extends IntentService { class PhoneListener extends PhoneStateListener { String TAG = getClass().getName(); @Override public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state,

Android RTL issue in API 24 and higher on locale change

霸气de小男生 提交于 2020-01-11 03:37:36
问题 I was trying to change locale of app at runtime. It is working fine in Andorid below API level 24. But in API level 24 or greater the layout direction is not changing according to locale. Below is the code to change the locale at runtime. I have used LocaleHelper class as below public class LocaleHelper { private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language"; public static Context onAttach(Context context) { String lang = getPersistedData(context, Locale.getDefault

Android 7.0 ble scan no result

好久不见. 提交于 2020-01-10 04:12:19
问题 When I start ble(Bluetooth Le) scan for seconds, then stop scan. Then start, then stop... after about 5-8 Loops, the start action will be No effect ,this means no scan record can be received. 1.This condition only appears on Android 7.0 or above(7.1.1); 2.I have tried two scan method: BluetoothAdapter.startLeScan() and Scanner.startScan(), no difference . private void scanToggle(final boolean enable) { mScanHandler.removeCallbacks(scanTask); if (enable) { TelinkLog.i("ADV#scanner#startScan");

Android: How to get a content:// URI for a file in the external storage PUBLIC directory

僤鯓⒐⒋嵵緔 提交于 2020-01-09 19:45:33
问题 I've followed this Google tutorial to start an intent to capture an image with new Intent(MediaStore.ACTION_IMAGE_CAPTURE) . The tutorial recommends using the public directory with getExternalStoragePublicDirectory which would work great for my app. But then their example instead uses getExternalFilesDir . Then to pass the URI of the file to the intent with MediaStore.EXTRA_OUTPUT I have to get a content URI because I'd like to target Android N. Before targeting N I would just pass a file://