android

Request Permission from Application class [duplicate]

时光怂恿深爱的人放手 提交于 2021-02-16 16:09:43
问题 This question already has an answer here : Android: ActivityCompat.requestPermissions requires activity and not context :/ (1 answer) Closed 4 years ago . As per the new Android doc, In order to collect certain data, I need to request for permission. So I am doing this : @Override public void onCreate() { super.onCreate(); ... ... if (PermissionUtility.isPermitted(applicationContext, android.Manifest.permission.READ_SMS)) { userNumber = getUserPhoneNumber(); } else { ActivityCompat

Kotlin: how to return running service instance in binder?

半世苍凉 提交于 2021-02-16 16:09:27
问题 I have working Java code for Service and trying to convert it to Kotlin . class MyService : Service() { companion object MyBinder : Binder() { fun getService() : MyService? { return MyService::class.objectInstance } } // service implementation } The problem is that in activities getService() always returns null. I am sure the service is started before, I see it in logcat. I suggest this auto generated line from Java code should be different but I cannot find the solution: return MyService:

Request Permission from Application class [duplicate]

蓝咒 提交于 2021-02-16 16:09:14
问题 This question already has an answer here : Android: ActivityCompat.requestPermissions requires activity and not context :/ (1 answer) Closed 4 years ago . As per the new Android doc, In order to collect certain data, I need to request for permission. So I am doing this : @Override public void onCreate() { super.onCreate(); ... ... if (PermissionUtility.isPermitted(applicationContext, android.Manifest.permission.READ_SMS)) { userNumber = getUserPhoneNumber(); } else { ActivityCompat

Kotlin: how to return running service instance in binder?

主宰稳场 提交于 2021-02-16 16:08:38
问题 I have working Java code for Service and trying to convert it to Kotlin . class MyService : Service() { companion object MyBinder : Binder() { fun getService() : MyService? { return MyService::class.objectInstance } } // service implementation } The problem is that in activities getService() always returns null. I am sure the service is started before, I see it in logcat. I suggest this auto generated line from Java code should be different but I cannot find the solution: return MyService:

Request Permission from Application class [duplicate]

ε祈祈猫儿з 提交于 2021-02-16 16:08:37
问题 This question already has an answer here : Android: ActivityCompat.requestPermissions requires activity and not context :/ (1 answer) Closed 4 years ago . As per the new Android doc, In order to collect certain data, I need to request for permission. So I am doing this : @Override public void onCreate() { super.onCreate(); ... ... if (PermissionUtility.isPermitted(applicationContext, android.Manifest.permission.READ_SMS)) { userNumber = getUserPhoneNumber(); } else { ActivityCompat

Request Permission from Application class [duplicate]

夙愿已清 提交于 2021-02-16 16:08:27
问题 This question already has an answer here : Android: ActivityCompat.requestPermissions requires activity and not context :/ (1 answer) Closed 4 years ago . As per the new Android doc, In order to collect certain data, I need to request for permission. So I am doing this : @Override public void onCreate() { super.onCreate(); ... ... if (PermissionUtility.isPermitted(applicationContext, android.Manifest.permission.READ_SMS)) { userNumber = getUserPhoneNumber(); } else { ActivityCompat

Change FAB background color when disabled

岁酱吖の 提交于 2021-02-16 16:01:14
问题 I'm trying to figure out how I can change the background color of the floating action button when it is disabled for a duration of 2 seconds after being pressed. I would also like it to return to its original color when the 2 second duration is over. This is the code for the 2 second delay when pressed. This code is in a fragment within the MainActivity. appBar.setExpanded(true, true); fab.setVisibility(View.VISIBLE); fab.setImageResource(R.drawable.ic_phone_white_18dp); fab

Glide: show image with radius corners only on top

时光总嘲笑我的痴心妄想 提交于 2021-02-16 15:53:05
问题 I use Glide. Here snippet: Glide.with(context).load(referenceUrl).into(holder.imageViewPhoto); OK. It's work fine. But I need image to show with radius corners only on TOP. Something like this: Is it possible by Glide? 回答1: You can use : requestOptions.centerInside().transform(new CenterInside(), new GranularRoundedCorners(topLeft, topRight, bottomRight, bottomLeft)) 来源: https://stackoverflow.com/questions/47350973/glide-show-image-with-radius-corners-only-on-top

How to get the default gmail username and password [closed]

笑着哭i 提交于 2021-02-16 15:42:08
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 days ago . Improve this question Now I am doing a android project. The project needs to get the default username and password of Android phone. I don't know how to get the default gmail information of one Android Cell Phone. Can u help me. Thanks. 回答1: You should read about AccountManager to login using the

Persisting data in a flutter application

天涯浪子 提交于 2021-02-16 15:32:13
问题 I am building an app and in it, I have the names of people in a list from which I could add/delete, etc.. The problem is this list is not saved when I close the app, which is inconvenient. I heard you can use shared Preferences to save simple objects like this, without complicating things like using SQLite and json. So I'd like to know what's the suggested way to persist this data and load it etc. Thanks in Advance and have a great day :) Here is the code: import 'package:flutter/material