android

How request permissions with Jetpack Compose?

落花浮王杯 提交于 2021-02-19 02:16:22
问题 How should be implemented requesting permission from Jetpack Compose View? I'm trying implement application accessing Camera with Jetpack Compose. I tried example from How to get Current state or context in Jetpack Compose Unfortunately example is no longer working with dev06. fun hasPermissions(context: Context) = PERMISSIONS_REQUIRED.all { ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED } } } 回答1: A little late but this might help as I had the problem

android -------- java.net.UnknownServiceException

我的梦境 提交于 2021-02-19 01:58:30
最近升级了Android的API版本时 ,导致我的网络请求失败了, 出现了这个错误 java.net.UnknownServiceException, 这个错误,我在网上查到这个主要是由于,我们的OkHttp3会默认使用密文传输,而我们的代码中使用Http协议,也就是使用明文传输,所以OkHttp3会主动的报错,然后阻止线程的运行。所以我们现在就是要修改配置文件,使OkHttp3允许使用明文传输,或者我们直接使用Https协议。 解决方法: 在 res 下新建一个 xml 目录,然后创建一个名为:network_security_config.xml 文件 该文件内容如下: <?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true" /> </network-security-config> 然后在 AndroidManifest.xml application 标签内应用上面的xml配置: <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android

Hint and Text in editText at same time

你离开我真会死。 提交于 2021-02-19 01:53:25
问题 I just need an editText in which i can set Text and hint at the same time. e.g i want user to enter in editText string like user#1234 in this string user# should be text after that numbers will vary so that 1234 should be show as hint when user try to enter cursor will go after # and 1234 hint will gone when user type a character. Please guide me how to do this. Thanks 回答1: I managed to achieved this with bit of tricks and playing with margin and padding This is what I did <RelativeLayout

Having a mySQL error, unknown column where clause [duplicate]

强颜欢笑 提交于 2021-02-19 01:45:07
问题 This question already has answers here : When to use single quotes, double quotes, and backticks in MySQL (13 answers) Closed 6 years ago . I am currently having a problem selecting a certain item from a mySQL database. My program is designed to pass a parameter from an android application to a servlet which then queries the database. However an error appears on the console window: Unknown column '0102310c24' in 'where clause' There is only an error when the value I want to select contains a

Start new Activity outside the Activity context.

三世轮回 提交于 2021-02-19 01:39:11
问题 I tried to start an Activity and close other in my AsyncTask class ( onPostExecute() ). My code : Intent i = new Intent(parentActivity, ThunderHunter.class); c.startActivity(i); parentActivity.finish(); But it doesn't work, logcat shows : 08-01 18:01:27.640: E/AndroidRuntime(12398): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 08-01 18:01:27.640: E/AndroidRuntime(12398)

Android UI Not Crashing When Modifying View off UI Thread

喜夏-厌秋 提交于 2021-02-19 01:35:29
问题 Scenario: I ran into a strange issue while testing out threads in my fragment. I have a fragment written in Kotlin with the following snippet in onResume(): override fun onResume() { super.onResume() val handlerThread = HandlerThread("Stuff") handlerThread.start() val handler = Handler(handlerThread.looper) handler.post { Thread.sleep(2000) tv_name.setText("Something something : " + isMainThread()) } } is MainThread() is a function that checks if the current thread is the main thread like so:

Cloud Firestore - Dynamic Querying

独自空忆成欢 提交于 2021-02-19 01:32:05
问题 I have a Collection in Cloud Firestore that has a certain number of items, let's call it Collection "X". This number of items will constantly be changing. At any given time, I want to listen for the number of items in this Collection and create several whereEqualto() calls on a Query object that is based on another 'Collection', let's call it "Y": Query queryStore = FirebaseFirestore.getInstance() .collection("Y") .whereEqualTo(USER_ID_LABEL, "item 1 from X") .whereEqualTo(USER_ID_LABEL,

How to install specific TTS engine programmatically in Android?

青春壹個敷衍的年華 提交于 2021-02-19 01:30:25
问题 I am trying to add to my app specific TTS engine - not system based, so each person will have another, but one for all. In documentation there is method:setEngineByPackageName(), which looks like it will make what I want. However, looking on other similar problems earlier I've found something using this method: https://stackoverflow.com/questions/12549086/selecting-required-tts-programmatically-in-android. It looks quite ok, but it is used after system checking if TTS engine is installed, and

How to install specific TTS engine programmatically in Android?

可紊 提交于 2021-02-19 01:30:13
问题 I am trying to add to my app specific TTS engine - not system based, so each person will have another, but one for all. In documentation there is method:setEngineByPackageName(), which looks like it will make what I want. However, looking on other similar problems earlier I've found something using this method: https://stackoverflow.com/questions/12549086/selecting-required-tts-programmatically-in-android. It looks quite ok, but it is used after system checking if TTS engine is installed, and

How to install specific TTS engine programmatically in Android?

你说的曾经没有我的故事 提交于 2021-02-19 01:30:12
问题 I am trying to add to my app specific TTS engine - not system based, so each person will have another, but one for all. In documentation there is method:setEngineByPackageName(), which looks like it will make what I want. However, looking on other similar problems earlier I've found something using this method: https://stackoverflow.com/questions/12549086/selecting-required-tts-programmatically-in-android. It looks quite ok, but it is used after system checking if TTS engine is installed, and