android-activity

Unable to start activity Resources$NotFoundException

北城以北 提交于 2020-06-25 09:19:07
问题 I've had an app published and running on google play for several months. Today I received an error from a user with a resource not found exception. I thought i may have forgotten some drawable. From the error i got the object ID (I took ID 0x7f030003 from the error) and looked for it in R.java to determine what object was missing. To my surprise I found that the IDis from my Main Activity, so I'm sure I've not forgotten this! My app starts with main and all other activities/fragments are

Android onBackPressed() is not being called?

心不动则不痛 提交于 2020-06-24 21:28:52
问题 in my MainActivity, which extends from AppCompatActivity, I want to override the onBackPressed method like so: @Override public void onBackPressed() { Log.d("MainActivity","onBackPressed"); Toast.makeText(getApplicationContext(),"onBackPressed",Toast.LENGTH_SHORT).show(); } but onBackPressed does not get called. How ever if I do not override onBackPressed, the application closes, when I press the backbutton and if I do override it it doesn't. The rest of my activity looks like this: public

how to view PDF from a list view which is fetch from Firebase database?

无人久伴 提交于 2020-06-16 19:04:49
问题 I have fetched a PDF list view from Firebase Database This is the code that i used to fetch public class ViewFiles extends AppCompatActivity { ListView myViewFiles; DatabaseReference databaseReference; List<uploadFiles> uploadDOCS; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_files); myViewFiles = (ListView) findViewById(R.id.myViewFiles); uploadDOCS = new ArrayList<uploadFiles>(); viewAllFiles();

Android set transparent background for a fragment

旧城冷巷雨未停 提交于 2020-06-11 16:53:06
问题 In my app I have single activity and and all other fragments I am setting background for activity from style.xml as below <item name="android:windowBackground">@color/very_light_gray</item> Now for only a perticular Fragment I want to set background transparent and I am not able to do that tried below code in Fragment did not work for me @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // create ContextThemeWrapper from the original

How to check permission is granted in ViewModel?

旧巷老猫 提交于 2020-06-11 02:37:06
问题 I need to ask permission for contacts and when application starts I'm asking,in ViewModel part I need to call method which requires permission. I need to check permission is granted by user or not and then call, but for checking permission I need to have access Activity. while in my ViewModel I don't have a reference to Activity and don't want to have, How I can overcome, the problem? 回答1: I just ran into this problem, and I decided to use make use of LiveData instead. Core concept: ViewModel

Is it safe to finish an android activity from a background thread?

放肆的年华 提交于 2020-06-10 09:24:09
问题 In Android, is it safe to call Activity.finish() from a background thread, or can it only called from the main thread? The documentation doesn't mention anything about thread safety of this method. 回答1: No, it is not. The code uses at least one variable, mFinished, without synchronization. Full stop. public void finish() { if (mParent == null) { int resultCode; Intent resultData; synchronized (this) { resultCode = mResultCode; resultData = mResultData; } if (false) Log.v(TAG, "Finishing self:

How to make multiple buttons open the same activity?

别等时光非礼了梦想. 提交于 2020-05-24 07:31:13
问题 I am new to Android and Java development and I am wondering how to make the buttons in the dashboard open the same activity but with different data for each fragment . this activity will work the same way for all the buttons the only thing changing is the sortalgorithm.java used 回答1: you can put a flag in your intent when you call startActivity(Intent intent) method. is something like this: //... Intent intent = new Intent(this, DisplayMessageActivity.class); Bundle b = new Bundle(); b

How to prevent one activity from resizing when keyboard opens

ε祈祈猫儿з 提交于 2020-05-24 05:21:50
问题 I want to prevent my activity from resizing when my keyboard opens. I know I can use android:windowSoftInputMode="adjustNothing" in my manifest folder to do that, but it applies the change to all of my activities. How can I apply this change to only one of my activities? I tried to add android:windowSoftInputMode="adjustNothing" to my activity but it didn't work. 回答1: Try this layout: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http

Can´t finish Activity

爱⌒轻易说出口 提交于 2020-05-24 05:17:49
问题 I have tried className.this.finish and finishActivity() to invoke the finishing of my activity and I have initialised the activity with the following methods - startActivityForResult() or finishAndRemoveTask() The propose of this activity is to register a device this is done when under Devices/(MAC address of the device)/Users/ it save in fire base up to 4 different notification tokens of 4 users different. So what I'm trying to do but it falling is to check if the number 1 have info, check 2

How to make notification intent resume rather than making a new intent?

旧巷老猫 提交于 2020-05-19 08:32:09
问题 What i have here is a simple webview activity that when loaded it auto displays an ongoing notification. The idea is that people can navigate away from this activity and quickly access it again from any screen they want by pulling down the drop down menu and selecting it. Then when they want they can just close the notification by hitting the menu button and hitting exit and then the notification clears. This all works fine. However, when the notification is pressed it starts a new instance