android-activity

What is Intent from onActivityResult Parameters

不想你离开。 提交于 2019-12-31 22:42:23
问题 Here is my first activity code from where I call the second Activity : @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT){ startActivityForResult(new Intent("chap.two.Chapter2Activity2"),request_Code); } return false; } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == request_Code) { if (resultCode == RESULT_OK) Toast.makeText(this,data.getData().toString(),Toast.LENGTH_SHORT)

How to clear stack back to root activity when user leaves application?

梦想的初衷 提交于 2019-12-31 21:43:10
问题 I have an application with 2 activities, LogonAct and MainAct. LogonAct is a logon activity which I want to force the user to go through each time they return to the application. I've set android:clearTaskOnLaunch="true" on LogonAct. When I first start the app I go through this sequence of screens, Home -> LogonAct -> MainAct -> Home I then follow this sequence, LogonAct -> Back -> MainAct Why is it bringing me back to MainAct? Shouldn't that activity haven been closed since LogonAct has

Android: Launch mode 'single instance'

空扰寡人 提交于 2019-12-31 20:30:14
问题 I was going through the documentation for single instance and was trying out few samples. In one of my sample I have three activities: A->B->C , where B has android:launchMode="singleInstance" in manifest. Activity A and C has default launch mode. Scenario: After navigating to C via A and B (i.e A->B->C), back button press from Activity C takes to Activity A (C->A), but back button press from Activity A does not quit the app, rather brings the Activity B to front, then back button press from

Android Array Adapter with ArrayList and ListView not updating when the arraylist is changed

偶尔善良 提交于 2019-12-31 13:30:22
问题 I have an android app with a screen that comprises of a ListView, which I am using to display a list of devices. These devices are held in an array. I am trying to use the ArrayAdapter to display what is in the array on the screen in a list. It works when I first load the SetupActivity class, however, there is the facility to add a new device in the addDevice() method, which means the array holding the devices is updated. I am using notifyDataSetChanged() which is supposed to update the list

How to share common layout between activities without fragment

只谈情不闲聊 提交于 2019-12-31 13:27:08
问题 Is there any possible way to share layout(part) between activities? For example, in my app, all activities have similar layout, the top part is long operation indicator (a progress bar, hidden when no operation is being executed), the bottom part is for showing errors. Only the middle part is different for all activities. See the picture below. so my question is, is it possible to reuse the common layout(loading and error part) for all activities in my app? (currently I don't want to use

Android - limit number of fragments in backStack?

我的未来我决定 提交于 2019-12-31 10:48:16
问题 Currently I have one activity, and fragments are being added to it (search, song details, settings, etc). I implemented side based menu navigation, so now, as a side effect, tehre's no limit to how many Fragments get added to the Backstack. Is there any way I can limit the number of fragments, or remove older entries? Each song details fragment for instance, has a recommended song list, and through that you can go to another song details fragment. It's easily possible to have 30 fragments in

How to know if my application is in foreground or background, android?

孤街浪徒 提交于 2019-12-31 10:04:16
问题 I need to check if my application is running in background or foreground and then perform some operations relatively to it. I searched a lot and a clear solution is not available. Make a parent activity in its onPause() and onResume() methods keep some variable to update them accordingly. When you create any new activity inherit your parent activity. Although this is the best solution I feel to achieve my task, but sometimes if the power button is clicked even though application is in

How to know if my application is in foreground or background, android?

偶尔善良 提交于 2019-12-31 10:04:10
问题 I need to check if my application is running in background or foreground and then perform some operations relatively to it. I searched a lot and a clear solution is not available. Make a parent activity in its onPause() and onResume() methods keep some variable to update them accordingly. When you create any new activity inherit your parent activity. Although this is the best solution I feel to achieve my task, but sometimes if the power button is clicked even though application is in

Send data from activity to fragment using Tab Layout with Swipeable Views in Android

别等时光非礼了梦想. 提交于 2019-12-31 07:04:10
问题 I created a Tab Layout with Swipeable Views using this tutorial. I'm trying to pass a string from Activity to Fragment. I read about fragment communication and couple other topics on stackoverflow but still i get null pointer exception. Here's my code: MainActivity.java public class MainActivity extends FragmentActivity { private static final int REQUEST_CODE_EMAIL = 1; String password, email; ViewPager viewPager; TabsPagerAdapter tabsPagerAdapter; ActionBar actionBar; @Override protected

Alert Box in Android doesn't let me to click, just directly performs the action

蓝咒 提交于 2019-12-31 06:23:10
问题 I've a button upon clicking should display an alertdialog box containing just "OK" button and upon clicking should go to another activity. But this dialog box appears for a few seconds and goes to the activity without letting me click or confirm it. This is the code i've used public void onClick(View v) { AlertDialog.Builder alertbox = new AlertDialog.Builder(InsertData.this); alertbox.setMessage("Object Location Stored!"); alertbox.setPositiveButton("Ok", new DialogInterface.OnClickListener(