w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
History Stack of activity clear in android
In your comments you suggested that you've tried using flags like: Intent i = new Intent(MainActivity.this,SecondActivity.Class); i.addFlags(android.flags.FLAG_CLEAR_TOP | FLAG_NEW_TASK | FLAG_CLEAR_TASK) But instead try using them like: Intent intent = new Intent(MainActivity.this,SecondActivity.Class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);

Categories : Android

Choose specfic Activity from Android Activity stack
First of all you need to understand what activity life cycle is. According to your requirement try this link this might help you. You can call which activity you want according specific result you had mentioned to your activity using startActivityForResult() method.

Categories : Java

How to know if the last closed activity was the last activity in the stack in Android?
Maintain the activity stack of your application. You can achieve this by many ways: If your application has multiple entry points, then you can track which activities your user has opened and where they currently are, and accordingly when the the stack is pushing out its last item, pop the service. If your app doesn't have multiple entry points, then you can just monitor the onStop of your Launcher activity. If you want to also stop your service while multi-tasking, you'll have to be more creative with intents and sending a few flags as payloads. Maybe stop the service onStop if a flag isn't set by starting another one of your activities.

Categories : Android

Android How to clear stack of an application if its open before launching by another appliction?
Would you be looking for the following flags to add to the Intent you start the other application with: FLAG_ACTIVITY_CLEAR_TASK

Categories : Android

How to clear values of all static variables at the end of an activity Android?
May these help you.. Using Static Variables is like a nightmare in any activity as it stores memory through out the activity.. I think you can try some other memory store to overcome your problem of passing value from one activity to another.. In my opinion u can store values in SharedPreference or either you can pass value through intent to other activity where ever it is required.. Hope these will help you.. EDIT: Intent in = new Intent(MainActivity.this,SecondActivity.class); You can use more than one putExtra() method to put several values and can fetch then in Second Activity in.putStringArrayListExtra(String name, ArrayList<String> value); StartActivity(in); In Second Activity: Intent in = getIntent(); ArrayList<String> Roleids = new ArrayList<String>;

Categories : Android

Get label name of top running activity in the stack Android
try this i dont know whether it help you or not , PackageManager pm = context.getPackageManager(); RunningAppProcessInfo info = am.getRunningAppProcesses().get(0); try { CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); System.out.println("the label of the app is " + c); Log.w("LABEL", c.toString()); } catch(Exception e) { //Name Not FOund Exception }

Categories : Android

Android: can you use an AlertDialog to clear data so it isn't corrupted after starting an email activity?
Android devices can behave very different, one from another. You could have slowness in your mail activity, or you could have your device to suddenly decide to clean up memory and make every thing slow slow slow for a moment. If you are relying on timing in hoping that some other process or thread is completed before you delete something, you are playing with fire. I think a better approach would be to start your e-mail activity for result, like CapDroid did in this answer: Send Mail: int EMAIL = 101; Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/html"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{}); emailIntent.putExtra(android.content.Intent.EXTRA_BCC,new String[]{}); emailIntent.putExtra(android.content.In

Categories : Java

Flag Activity Clear Top destroys target activity and than creating it
Use FLAG_ACTIVITY_REORDER_TO_FRONT and then use an intent to tell B to finish. Activity B: private BroadcastReceiver finishReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { finish(); } }; public void onCreate() { LocalBroadcastManager.getInstance(this) .registerReceiver(finishReceiver , new IntentFilter("B-finish")); } public void onDestroy() { LocalBroadcastManager.getInstance(this).unregisterReceiver( finishReceiver ); } Activity C: LocalBroadcastManager.getInstance(this).sendBroadcast( new Intent("B-finish")); Intent intent_to_a=new Intent(C.this,A.class); intent_to_home.setFlags(Intent.FLAG_ACTI

Categories : Android

Start a new activity clearing the activity stack
You could create a parent activity which is overriding the OnNewIntent, when receving an intent with EXIT extra finishes itself.note that you have to call it with the SINGLE_TOP flag, so the OnNewIntent will be called. then create a static method which broadcast an exit intent to all of your activities that inharnace this parent activity. This should work even if you have move than one tasks.

Categories : Java

How to Clear the Stack and close the application
Closing all the previous activities as follows: Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("Exit me", true); startActivity(intent); finish(); Then in MainActivity onCreate() method add this to finish the MainActivity if( getIntent().getBooleanExtra("Exit me", false)){ finish(); } Also check out this link

Categories : Android

CSS can neighboring children/content clear each other to stack
It seems that you may need to re-think the structure of your html. For one, using inline-styles is a bad practice because it can make code difficult to maintain and less readable. Also, considering the different blocks of color used throughout being content of the .child divs, these content areas should probably be separate divs nested within the .child divs. So, if I have understood correctly, here is the HTML: <div class="contain"> <div class="row"> <!-- parent div: --> <div class = "parent"> <div class = "child"> <div class = "red"> </div> <div class = "yellow"> </div> <div class = "blue"> <

Categories : CSS

How to get actionbar home button to clear nav stack?
If you dont want to create a new instance of an activity you have Manage Android Tasks manually. If you want to provide Up Navigation in your app you have specific parent-ancestor relationship in the AndroidManifest.xml You only have to create a new back stack only if your activity is starting from a different app. Follow Android Official Guide for implementing navigation Always first take a look on official Android docs before learning something new about Android before following any unofficial blog.

Categories : Android

Get data from an activity in AppWidget after clear memory
To store data, u need service ruining in background. http://developer.android.com/reference/android/app/Service.html#startForeground(int, android.app.Notification) And to comunicate with serive use BroadcastReciver. http://developer.android.com/reference/android/content/BroadcastReceiver.html

Categories : Android

Finish leaves activity in stack
Assuming that the history button you refer to is the list of recent apps, you can set android:excludeFromRecents="true" By default value for this attribute is false. For other attributes check the link: http://developer.android.com/guide/topics/manifest/activity-element.html

Categories : Android

Clearing Activity Stack on Intent Start
Have you tried finishing the current activity? if (haveCredentials()) { Intent i = new Intent(this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); finish(); //add this! }

Categories : Java

Fail to resume the activity stack during 1st launching after installation
I'm not really able to tell what's going on without knowing more about your app. I would look into: The launchMode manifest element: android:launchMode Check your activities are not being destroyed and recreated by the system: Recreating an Activity If you are doing anything with fragments and if these are maintaining state correctly Sorry, bit of a guess!

Categories : Android

How to add call a callback in the Activity when there is a Fragment pushed from back stack
no need to callback anything! let's say for example that the layout where your fragments get replace on each transaction is R.id.mycontent so instead of having the TAG in a field you can, on each click on the drawer, do this: String currentTag = getSupportFragmentManager.findFragmentById(R.id.mycontent).getTag(); and with this one you compare to what was clicked.

Categories : Android

Is there a FLAG_ACTIVITY_**** to bring a previous Activity to front and finish all the others between the stack?
Try with this: case android.R.id.home: Intent intent = new Intent(this, ActivityA.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); return true;

Categories : Android

Error to pass from activity with Navigation Drawer to activity with relative layout Android
You should change convertView = inflater.inflate(R.layout.myprofile_user_item_layout, parent, false); to convertView = inflater.inflate(R.layout.myprofile_user_item_layout,null); Since you are not depending on the parent layout for parameters you should not specify it in the inflating of the layout that you are.

Categories : Android

Android Main activity listening and receiving values/signals from another activity periodically
The code that is running in MainActivity needs to be moved to a service or something that has a lifecycle independant of which is currently displayed on the screen. This is because Activities can be killed off by the OS while they are not in focus. I would suggest an IntentService that when it runs it does the periodic task you need then schedules itself to run again via a pending intent. A good example of this is here: http://www.vogella.com/articles/AndroidServices/article.html

Categories : Android

android eclipse: switch activity briefly shows previous activity screen
This depends on what phone you're using since different phones use different anamations. Try to call finish(); on every activity but your main one for example.. Or finish them all when the user switches activities

Categories : Java

How to start splash activity(very first activity) from left to right animation effect in android
Replace "view" with your outermost Layout name. Write this code in your oncreate method of the activity that you want the animation to occur. animationSlideInLeft = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); animationSlideInLeft.setDuration(1500); animationSlideInLeft.setAnimationListener(new AnimationListener(){ @Override public void onAnimationEnd(Animation animation) { // if you need to do something } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { }}); view.startAnimation(animationSlideInLeft);

Categories : Android

transfer data of 5 activity pages 26 edit text fields and calculate in last android activity
I think you have to create ArrayList<String> data = new ArrayList<String>(); for each activity when onClick(). Press "add all data" to ArrayList, pass this ArrayList into intent, put extra, on 2,3,4 activity you get previous activity data from getIntent() add your current activity data and pass on next activity and last activity do your calculation with previous and current data. /**First Activity**/ ArrayList<String> data = new ArrayList<String>(); @Override public void onClick(View v) { data.clear(); data.add(tA); -------------- -------------- data.add(tZ); Intent intent = new Intent(SecondActivity.class, FirstActivity.this); intent.putStringArrayListExtra("IN_PREVIOUS_DATA", data);

Categories : Android

Android Passing values from one activity to other activity (string) or from one class to another
First of all take a spinner and provide value to them what you want and then the selected spinner value change it to string value and this string variable will be used in OK button to pass value through use of Intent or Shared preference to take this value to another activity and through there you can use it in database to display this value.

Categories : Android

Can't get onActivityResult when starting an activity from a child activity in TabActivity Android
I know this isn't really the answer you're looking for, but you're using deprecated API. You should try a refactor and use the new Fragment API and the v4 support library if you need to support older versions of Android too. Using fragments you won't need to rely on setResult and onActivityResult. Fragment Fragment Tab Host

Categories : Android

Android: when Activity receives a broadcast how to detect if sender is the Activity itself?
I'm not aware of if there's a specific way of doing this, but, I would add a specific action to my Intent that is being broadcast. It could look like this: Intent broadcastIntent = new Intent(MyClass.class.getName()); sendBroadcast(broadcastIntent); Then when you receive the broadcast, you'll simply just check for the specific action: @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(MyClass.class.getName()) { // Ignore the broadcast as it's the caller calling itself... } else { // Do something with the broadcast... } } There might be other ways to do this (like just putting extras into the Intent and then reading it out in the onReceive method), but I find this to be a really simple way of getting who the call

Categories : Misc

How to use same android button to start an activity and do a function in previous activity?
Use something like this: Intent intent = new Intent(this, YourSecondActivity.class); startActivity(intent); In your onClick, this would be: btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { String mobileno=pno.getText().toString(); String text=msg.getText().toString(); sentsms(mobileno,text); Intent intent = new Intent(this, YourSecondActivity.class); startActivity(intent); } });

Categories : Android

Android Activity onCreate Being Called Twice When Navigated Back From Another Activity
It seems you are getting multiple instance of your first activity. use this in manifest of 1st activity: android:launchMode="singleTop" else call finish() after doing startActivity() for 2nd activity

Categories : Android

What is the activity class name of the Android native phone app dial activity?
try this for reading logs- try { Process process = Runtime.getRuntime().exec("logcat -d"); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream())); StringBuilder log=new StringBuilder(); String line = ""; while ((line = bufferedReader.readLine()) != null) { log.append(line); } TextView tv = (TextView)findViewById(R.id.textView1); tv.setText(log.toString()); } catch (IOException e) { }

Categories : Android

Adding and Removing Dynamic Buttons From one activity to another activity in android on click of button from previous activity button click
In the first activity's onClick send the data using Intent: intent = new Intent(this, PCode.class); intent.putExtra("EXTRA_BTN_NAME", editText.getText()); intent.putExtra("EXTRA_WHERE", where); startActivity(intent); In the new activity you should get the data with @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activty2); Intent intent = getIntent(); String btnName = intent.getStringExtra("EXTRA_BTN_NAME"); where= intent.getStringExtra("EXTRA_WHERE"); LinearLayout l1 = (LinearLayout) findViewById(R.id.layout); Intent intent1 = new Intent(context1,PCode.class); Button b = new Button(this); b.SetText(btnName); //TODO - use the "where" parameter l1.addView

Categories : Android

Android Traceview Shows Activity Takes 2200 msec to Create Activity (onCreate through to onResume), How do I Determine Why?
One of the things that can really hurt you is to have layouts whose measuring affect each other. I would be that you are using lots of "weights" in your layout, as these are a bit time intensive to calculate. You can analyze your slow layout using hierarchyviewer. This is in the Android tools menu in IntelliJ or in Eclipse. It only runs on test devices, or with apps that have added ViewServer (see this for instructions) One note-- green, yellow, and red are relative to your current view Hierarchy. Here is a note from the documentation: These indicators can be red, yellow, or green and represent how each view renders in relation to other views in the tree. They are not a strict representation of a bad or good view, per se. A red dot means that this view renders the slowest, c

Categories : Android

Android Login Activity and Home Activity redirection
As far as my experience goes, I also use the shared preferences for Login page/Home Page redirection. The only difference is, my first page is a splash screen which I show for a certain duration of time. After that I check the logged in status with the shared preferences, and do the necessary redirection. One point should be noted here though, some servers require you to send new login request after a certain duration (configurable value sent from the server as part of login response) has passed. So you might want to take a look at that. In another one of my apps, I need to send a login request every time the app is launched, so I just store the login values (userName/Pass) in the shared prefs after the first login, and do the login part silently (without showing the login screen) after

Categories : Android

Android notification opens last activity instead of proper activity
You may want to add the Intent.FLAG_ACTIVITY_REORDER_TO_FRONT flag to your Intent. This will ensure that the CommentActivity is the resumed and active Activity when the intent is handled.

Categories : Java

How to Send list of data from one activity to another one activity in android
Finally i completed using the parcelable in my class public class Channel implements Serializable, Parcelable { /** */ private static final long serialVersionUID = 4861597073026532544L; private String cid; private String uniqueID; private String name; private String logo; private String thumb; /** * @return the cid */ public String getCid() { return cid; } /** * @param cid * the cid to set */ public void setCid(String cid) { this.cid = cid; } /** * @return the uniqueID */ public String getUniqueID() { return uniqueID; } /** * @param uniqueID * the uniqueID to set */ public void setUniqueID(String uniqueID) { this.uniqueID = uniqueID; } /** * @return the name */ public String getName() { return name; } /** * @param name *

Categories : Android

Android launch other activity before launching splash activity
Looks like its a bug in the api! Simply add this in your starter activity declared in your manifest: <activity ... android:theme="@style/Theme.NoActionBar" > <intent-filter> ... </intent-filter> </activity> And if you are using ActionBarSherlock <activity ... android:theme="@style/Theme.Sherlock.NoActionBar" > <intent-filter> ... </intent-filter> </activity> Your question is rather similar than this one

Categories : Android

How to pass data from a non-activity class to an activity in android?
as far as i understood the question, you start your activity, from there you start your CommunicationHandler instance? then you'll let your activity implement any kind of CallBack interface, instantiate your Handler with the CallBack (means: the activity) and call the CallBacks call method. see this question and it's answer for some more details on how to use callbacks sorry if i understood it wrong :-) edit: Your MainActivity (the one starting your SocketConnector and receiving the messages) should provide an implementation of a callback interface. the interface could look something like this: public interface IMessageReceiver { public void onMessageReceived(Message m); } with your Message class looking like: public class Message { String name; String msg; //add getter/s

Categories : Java

How do I refresh an activity in android with new variables from another activity
If you're recreating the Actitity with an Intent, you can add Intent extras: yourIntent.putExtra("Date", date.toString()); and retrieve it in onCreate(): date = getIntent.getStringExtra("Date"); To change the titlebar though, you should only need to do this: setTitle(date.toString());

Categories : Android

ANDROID: Start same Activity from 2 different Activity (different Intent)
create an static object with static field intent when calling the activity for first time(check if its null). So next time you call the same activity from another class use this same static object having the already set intent to call the activity again and hence you will find those extras!

Categories : Java

Android - how can i transfer ImageView from one activity to another activity?
First of all you need to understand that when you are getting an image using the camera activity this way you are getting a thumbnail version of the taken image. in order to get a full size image it has to be saved, you can take a look at this blog post I wrote on this matter for more information: Use Camera Activity for Thumbnail and Full Size Image Now for your question, I think that the best option would be to save this image to a file (described in the guide) and pass an extra to the following activity with the string path of the image.

Categories : Java

Android Context without being in an activity? And other activity-less programming?
EDIT: If possible, use frogmanx's answer. This should only be used when his answer is not possible to use. (ie. singletons that need a context right off the bat.) Sounds like you should extend Application and not Activity. Also, use the Log class instead of println(). Make your Application something like this: public class MyApplication extends Application { private static MyApplication instance; public MyApplication() { instance = this; } public static MyApplication getInstance() { return instance; } Then add this attribute to the application tag of the manifest: <application android:name=".your.package.MyApplication" ... /> After all that, you can get a Context by calling MyApplication.getInstance() from anywhere.

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.