android-activity

Kotiln: pass data from adapter to activity

微笑、不失礼 提交于 2020-01-24 10:32:20
问题 I try to pass my data from the adapter to my other activity with a putExtra but when I click on an item in my list to move to my second activity , no data is retrieved and the default text I put in is not displayed. another way to do? or What do I miss about it? Here my code : My onBindViewHolder : override fun onBindViewHolder(holder: AlbumsListViewHolder, position: Int) { val AlbumsData = albumsData!![position] holder.albumsName.text = AlbumsData.title Glide.with(holder.itemView) .load

BadTokenException: Unable to add window — token null is not valid; is your activity running? in activity.isFinishing statment

走远了吗. 提交于 2020-01-24 03:50:31
问题 I have a popUpWindow that need to by displayed, after couple of seconds if the user is still on current activity. I implemented stament that check if the activity isnt finished/destroyed and then display the Popup, and it works fine, for weekend users :) ( slowly clicking from activity to activity) but in high pressuretests ( activities are recreating, finished, fast move form activity to activity) that gives me that error : E/UncaughtException: android.view.WindowManager$BadTokenException:

how to get the Context Inside the FirebaseMessagingService?

不问归期 提交于 2020-01-24 03:46:27
问题 I have an app and It Uses FCM for sending and receiving messages. I have implemented every thing as suggested in docs. Now on generation of token I want to save that into the Shared Preferrences. but it is giving error on that . Consider the name of class is like public class MyFirebaseMsgAndTokenService extends FirebaseMessagingService { private static final String TAG = "C_MyFirebaseIIDService"; @Override public void onNewToken(String newToken) { super.onNewToken(newToken); Log.d(TAG,

Using previous running activity instead of starting a new one

我的未来我决定 提交于 2020-01-24 01:08:42
问题 it is possible to Use previous running activity instead of starting a new one without affecting the back stack? for example activity A -> B -> C -> A i want to achieve that the system will use Activity A instanse without starting a new one, and without affecting the back stack. so when user will click Back he will travel the original path and the last activity will be A not B, by using simply singleTop/ReorderToFront flag i will be able to use the original activity but i will lose the back

Using previous running activity instead of starting a new one

六眼飞鱼酱① 提交于 2020-01-24 01:08:25
问题 it is possible to Use previous running activity instead of starting a new one without affecting the back stack? for example activity A -> B -> C -> A i want to achieve that the system will use Activity A instanse without starting a new one, and without affecting the back stack. so when user will click Back he will travel the original path and the last activity will be A not B, by using simply singleTop/ReorderToFront flag i will be able to use the original activity but i will lose the back

Android, how to get information on which activity is currently showing (in foregorund)?

杀马特。学长 韩版系。学妹 提交于 2020-01-23 17:40:08
问题 I wonder if there is a way to get information on which activity currently has focus (is in the foreground)? I am using instrumentation and I would like to know which activity is currently running in the application that I am testing against. Thanks 回答1: Take a look at Robotium 'a open-source test framework created to make automatic black-box testing of Android applications significantly faster and easier than what is possible with Android instrumentation tests out-of-the-box.' Homepage: http:

Android - Background activity bring itself to foreground

大憨熊 提交于 2020-01-23 13:26:04
问题 I have the following situation: Activity A starts activity B User presses Home button & starts another app After a while, I want activity B to bring itself (not create new instance) to foreground How can I do this? I tried using intents with FLAG_ACTIVITY_REORDER_TO_FRONT, FLAG_FROM_BACKGROUND and set B's launch mode as singleTask, singleInstance but none of them work. 回答1: Just use this method in your activity as per your situation. it will work. protected void moveToFront() { if (Build

How to be notified when activity/task changes in Android

拟墨画扇 提交于 2020-01-23 05:51:05
问题 I'm building a system status logger. I'd like to be notified when any activity/task is brought to the stop of the stack and becomes visible by the user (not just the one I wrote). ActivityManager makes it possible to work out what's on top: http://developer.android.com/reference/android/app/ActivityManager.html however, this requires that I frequently poll to recalculate what's on top wasting a lot of resources. Is there a way to receive an event/callback/notification when an activity changes

How do I change my button image with navigation drawer opening and closing

坚强是说给别人听的谎言 提交于 2020-01-23 02:56:10
问题 I have a navigation button for my navigation fragment which turns active and opens a navigation drawer menu upon click: Now when I click it, it turns active as follows: However, I want to associate it with a navigation drawer such a way that, even if I do not click the button and slide open the navigation drawer, the button turns active when the navigation drawer menu is open and when closed by sliding back in from right to left, the button turns red/inactive. The code which I am trying to

Reload SharedPreferences on resume? (or how to refresh/reload activity)

一个人想着一个人 提交于 2020-01-23 01:55:49
问题 How can I reload SharedPreferences when I resume from one activity to another? If I resume, it is possible that user has changed the settings. Is it possible to reload SharedPreferences or do I need to refresh/reload activity. And if, then how? 回答1: There is no difference in how you get and set SharedPreferences normally and from doing so in onResume . What you will need to do in addition to getting the most recent preferences, is update any objects you have in the Activity that use