android-7.0-nougat

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

我的未来我决定 提交于 2020-01-09 19:45:10
问题 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://

Android N Java8 java.time

混江龙づ霸主 提交于 2020-01-09 05:21:32
问题 I updated to the latest Android N sdk. The only thing I don't understand is why I cannot import java.time into my code? I thought Java8 is available through Android N. Then why didn't Google add java.time package? 回答1: Android N is not supporting all the features of Java 8. Following features are only supported: Default and static interface methods Lambda expressions Repeatable annotations Reflection and language-related APIs: java.lang.FunctionalInterface java.lang.annotation.Repeatable java

Is there a way to set a Quick Settings Tile's default state?

試著忘記壹切 提交于 2020-01-04 11:03:03
问题 I'm messing around with the Quick Settings API in Android N / API 24, and while I think it's pretty well thought out, I can't seem to find a way to set a Tile's default state to Tile.STATE_ACTIVE... I've tried setting the state in my service's onCreate method, but the getQsTile() method seems to return null at times. Currently, I'm overriding onStartListening(), and am setting the state there, but this seems to cause a flickering effect most of the time. Is this just something that isn't

Activity onStop() not called when home button is pressed in Android N multi window mode

主宰稳场 提交于 2020-01-03 07:28:07
问题 I am trying to make our video app to support Android N multiwindow mode. I have discovered that activity lifecycle becomes confused in multiwindow mode. The phenomenon is when our app layouts on the top screen with the whole screen in portrait, then I click the Home button, the upper app onPause() called but onStop() not called. According to the google guideline https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle, video app should pause video playback in onStop()

Getting the path to SD card

冷暖自知 提交于 2020-01-02 11:06:46
问题 Please read the whole post before down-voting and/or marking it as a duplicate! I'm working on an app that reads files from within a specific folder on the user's phone - either from the SD card (if there's one) or from the built in storage. Yes, the "READ_EXTERNAL_STORAGE" is mentioned in the manifest and I'm also handling the permission popup for API>23. I used to simply use File folder = new File(Environment.getExternalStorageDirectory(), "myfolder"); to get the path of the folder that is

SSL handshake exception while connecting over https using self signed certificate in android Nougat

非 Y 不嫁゛ 提交于 2020-01-01 19:43:16
问题 In my android application i connect over https. I am using a self signed certificate to connect. It is working on devices below api level 24 (before android nougat).But on android Nougat it throws the SSL Handshake exception : javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. This is how i connect over https:- SSLContext context = null; try { KeyStore keyStore = KeyStore.getInstance("PKCS12"); // Get the raw

Android 7.0 Not able to get list of files under “/” directory

不打扰是莪最后的温柔 提交于 2020-01-01 07:03:11
问题 Before Android 7.0, i was able to get list of files under "/" directory, but on Andorid 7.0 version i am getting null when i try t get list of files from "/" directory. Below is my code: File root = new File("/"); File[] files = root.listFiles(); 回答1: From android 7.0 they have applied more restrictions. Now you need to get access for individual directories. Check this link out for more information. 回答2: I was facing a similar issue with Android 7.0. Try using "/storage/emulated/0" instead of

File system changes in Android Nougat

人盡茶涼 提交于 2019-12-31 08:46:05
问题 Ever since the first release of the Android N developer preview, I get "permission denied" errors when attempting to list the root directory or other system directories. The permissions on these directories didn't seem to change (as far as I can tell). Question: What change(s) in Android N caused these permission denied errors? How to replicate: In ADB shell, run the following commands: run-as com.debuggable.packagename ls / This gives permission denied errors on Android N. Why list system

Android Alarm Manager setExactAndAllowWhileIdle() not working in Android 7.0 Nougat in Doze mode

徘徊边缘 提交于 2019-12-30 01:51:05
问题 I am trying to make an alarm fire in my app every 30 minutes using Alarm Manager's setExactAndAllowWhileIdle but it is not working! I test the functionality by issuing a push notification whenever I receive an alarm signal. The problem is: when the device enters doze mode after being idle for sometime, I no longer receive alarms. However, as soon as I turn On the screen, I receive a notification. My app needs accurate alarms that need to be delivered exactly on-time every 30 minutes! It can

How to share current app's APK (or of other installed apps) using the new FileProvider?

♀尐吖头ヾ 提交于 2019-12-29 08:07:51
问题 Background In the past, it was easy to share an APK file with any app you wanted, using a simple command: startActivity(new Intent(Intent.ACTION_SEND,Uri.fromFile(filePath)).setType("*/*")); The problem If your app targets Android API 24 (Android Nougat) or above, the above code will cause a crash, caused by FileUriExposedException (written about it here, and an example solution for opening an APK file can be found here) . This actually worked for me fine, using below code: File apkFile = new