android-activity

Is there anyway to get the position of android menubar item?

白昼怎懂夜的黑 提交于 2021-01-28 10:27:22
问题 I need to load Android dialog activity window once clicked on the icon in the action bar as displayed in the following image: I know how to load the window using the following code. resolver=getContentResolver(); layoutParams=getWindow().getAttributes(); layoutParams.x=400; layoutParams.height=600; layoutParams.width=1000; layoutParams.y= 30; this.getWindow().setAttributes(layoutParams); What I need to know is if there is any way to find out the position of the icon in action bar, without

How to call another activity method in android studio?

风格不统一 提交于 2021-01-28 07:52:33
问题 I have two different activities. The first calls the menu(base) if the user is logged in, but have also the method for display the user information. public class MainActivity extends ActionBarActivity implements View.OnClickListener { UserLocalStore userLocalStore; EditText etName, etAge, etUsername; Button bLogout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); etUsername = (EditText) findViewById(R

My app crash as soon as I select a image?

你。 提交于 2021-01-28 06:46:57
问题 I am completely new to Android Studio and I have been trying to make an app that scans using the (:scanLibrary) given by this link and followed the instructions given here https://github.com/jhansireddy/AndroidScannerDemo. There is no compilation error but only some runtime error. Can someone help me figure out why this is happening? This is my code package com.mukesh.android.digiwrite; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android

How to work with preference in single activity design using navigation component?

◇◆丶佛笑我妖孽 提交于 2021-01-28 06:20:27
问题 I want to migrate to single activity design using navigation component. I am using one activity and others are fragment. For some screens, I have only layouts, no preference. No problems to inflate those in fragment. But i faced problem when i try to work with preference. My requirements is: I need to inflate a toolbar and preference list in a fragment. My approaches: Add preference using this following code. SettingFragment.java @Override public void onCreatePreferences(Bundle

How to close all activities in Android and close from Task Manager?

送分小仙女□ 提交于 2021-01-28 05:57:24
问题 I want close android app int id= android.os.Process.myPid(); android.os.Process.killProcess(id); This code kills the Process. 回答1: If you always want your app to start with the root activity (the first activity) every time the user launches the app from the home screen or returns to it from the list of recent apps, then add this to the manifest in the <activity> tag for your root activity: android:clearTaskOnLaunch="true" However, if you want to just finish all activities in the current task

Releasing memory from activity of foreground service

佐手、 提交于 2021-01-28 00:11:25
问题 I have an app with a foreground service and one activity. The service can either start on its own on boot, or be started from within the activity. I have noticed when the service starts itself on boot, the memory usage is ~3mB. Once I open the activity, memory usage jumps up to about ~9mB. Once the activity has been opened (and then closed either by back or home button), the memory never drops back down to 3mB, even after many hours and other apps opening. My question is, should the memory

Shared Element Transition when reopening existing Activity in stack Reorder To Front

天大地大妈咪最大 提交于 2021-01-27 04:29:08
问题 I have an Activity A from there I open Activity B, and pass the shared element to it. It animates the transition fine, but when I go back to Activity A and then go to Activity B again which is still in the stack using intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); The shared element transition is not run. With regular animations you call overridePendingTransition() in onNewIntent for the animations to run. https://stackoverflow.com/a/8327091 I tried calling

Call requires API level 16 (current min is 14)

不羁的心 提交于 2021-01-04 04:17:31
问题 I have this line in my code: linearLayout.setBackground(drawable); setBackground() shows the following error: Call requires API level 16 (current min is 14) What does this mean? Can I raise my API level? What does a higher/lower API level mean? Does it limit the amount of devices my app can be used on if the API level is higher? 回答1: What does this mean? It means that the setBackground(Drawable) method was added in API Level 16, and older devices do not have it. However, your app's

How to swipe one row of RecyclerView programatically (at run time)?

半城伤御伤魂 提交于 2020-12-29 13:22:52
问题 I have a RecyclerView with items inside like this: I use ItemTouchHelper.SimpleCallback to listen for swipe and onChildDraw() to draw a canvas when items are swiped: A bit more swipe: My problem: I want to simulate a swipe (at run time) just on first item inside the list of items; I need first item to go (more or less ) -100 px on its X axis and then go back to original position. How to achieve this? 回答1: I created some utility method in case someone needs it import android.animation

How to check if the current activity has a dialog in front?

旧时模样 提交于 2020-12-28 14:00:40
问题 I am using a third-party library and sometimes it pops up a dialog. Before I finish the current activity, I want to check whether there is a dialog popped up in the current context. Is there any API for this? 回答1: You can check it running over the active fragments of that activity and checking if one of them is DialogFragment, meaning that there's a active dialog on the screen: public static boolean hasOpenedDialogs(FragmentActivity activity) { List<Fragment> fragments = activity