android-activity

Android: Remove a series of Activites on clicking back

大憨熊 提交于 2020-01-21 19:19:51
问题 Hello my application works like this now.. Main -> SEARCH -> ActivityA -> SEARCH -> ActivityB And when I click back from ActivityB, I want to do the following Main <- SEARCH <- ActivityB i.e I want to skip activities ActivityA and SEARCH. I know I have to use the FLAG, but how? 回答1: may be this be helpful Android: Clear the back stack 回答2: You coud just do: In SearchActivity Intent i = new Intent(this, ActivityA.class); i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActivity(i); In

Non-exported activities: launched on emulators; SecurityException on phones

限于喜欢 提交于 2020-01-21 11:35:34
问题 I have a non-exported activity in my project. If I try to launch it on my phone using adb : adb shell am start -n "packagename/activityname" I get the error: java.lang.SecurityException: Permission Denial: starting Intent { ... } from null (...) not exported from uid ... But, if I run the same command on an emulator, then everything works Okay. How comes? 回答1: But, if I run the same command on an emulator, then everything works Okay. How comes? An emulator instance runs as root by default,

How to manage activity with startActivityForResult

无人久伴 提交于 2020-01-20 08:51:10
问题 I got a situation like this: Activity A --> B --> C --> D, when D finished, I have to refresh ActivityA to display what I input in ActivityB , ActivityC and ActivityD.Here is my code: ActivityA @OnClick(R.id.btn_one) public void toActivityB(){ Intent intent = new Intent(); intent.setClass(this, ActivityB.class); startActivityForResult(intent, 1); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data);

NullPointerException On Android.os.Bundle

荒凉一梦 提交于 2020-01-20 05:19:09
问题 I have some problem with my code, when I need to transfer some data from one Activity to another one. First Activity ( ViewCashflow ) and I want transfer some data from ViewCashflow to second Activity ( NewTransaction ). Here its working well with no error, the data transferred successfully. But, I don't know what's going on when I run the second Activity directly (not from first Activity like before when I transfer the data) I got null pointer exception on the method that I use to receive

NullPointerException On Android.os.Bundle

蹲街弑〆低调 提交于 2020-01-20 05:19:05
问题 I have some problem with my code, when I need to transfer some data from one Activity to another one. First Activity ( ViewCashflow ) and I want transfer some data from ViewCashflow to second Activity ( NewTransaction ). Here its working well with no error, the data transferred successfully. But, I don't know what's going on when I run the second Activity directly (not from first Activity like before when I transfer the data) I got null pointer exception on the method that I use to receive

What is the purpose of using moveTaskToBack() method in android?

天涯浪子 提交于 2020-01-19 10:34:00
问题 I am using moveTaskToBack() method in my activity. When I am pressing back button the activity still is visible. The back key does not work. What did I do wrong here? I want to navigate back to the previous activity. public void onBackPressed() { // TODO Auto-generated method stub moveTaskToBack(true); new Finalizer().killApp(false); super.onBackPressed(); } 回答1: The purpose of moveTaskToBack: http://developer.android.com/reference/android/app/Activity.html moveTaskToBack(boolean nonRoot)

What is the purpose of using moveTaskToBack() method in android?

喜你入骨 提交于 2020-01-19 10:30:06
问题 I am using moveTaskToBack() method in my activity. When I am pressing back button the activity still is visible. The back key does not work. What did I do wrong here? I want to navigate back to the previous activity. public void onBackPressed() { // TODO Auto-generated method stub moveTaskToBack(true); new Finalizer().killApp(false); super.onBackPressed(); } 回答1: The purpose of moveTaskToBack: http://developer.android.com/reference/android/app/Activity.html moveTaskToBack(boolean nonRoot)

Add layout with parameters programmatically Android

只谈情不闲聊 提交于 2020-01-19 09:52:51
问题 Hello I have a main screen. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/> <ImageButton android:id="@+id/imageButton1" android:layout_width="55dp" android

Add layout with parameters programmatically Android

不想你离开。 提交于 2020-01-19 09:51:08
问题 Hello I have a main screen. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/> <ImageButton android:id="@+id/imageButton1" android:layout_width="55dp" android

android:configChanges=“orientation” does not work with fragments

有些话、适合烂在心里 提交于 2020-01-18 04:52:36
问题 I am just trying to adapt some of my applications for HoneyComb. The issue iI am facing is the destruction of my activity on orientation change (landscape/portrait) When I was using a classic activity, I wrote in the manifest: But now, all these lines aren't working anymore! Is there a workaround for that? My code: <activity android:name=".TwitterActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" /> <activity android:name=".TwitterActivity