Android : Close Current Activity When An Action Happens In Custom View
Oct 13, 2010
I have a toolbar view set for most of my activities.
The toolbar has several buttons which all trigger certain intents. Now, the problem is: how can I close current activity before starting another one ?
Problem 1) Activity cones For instance one of the buttons ('A') starts activity A. Activity A also has toolbar. If you press on the 'A' button, a new A activity will be started. I suppose I can look at Activity.getInstanceCount(), right ?
Problem 2) Unnecessary activities The activity X is not needed any more if the opts for A. I just want A then. How can I remove X from toolbar which only has access to context ?
I, of course could find toolbar view inside activity X and override the onClicks, but in general this would mean doing so for all my activities !? Am I on the right track ?
View 2 Replies
Sep 26, 2010
How do I close a whole hierarchy of activities and show a new activity not present in the current task?
Context
Consider a FTP browser that resumes the previous session on launch. Each folder is displayed in its own activity. When I click on a folder, a new activity is started for the folder. If I press the back button, the app returns to the previous activity, which corresponds to the the parent folder.
I can logoff from the menu at any time. Logging off should bring me to the login activity (not present the current task when the app has resumed the session), and close all the other activities. How can I do this?
From what I've read, if the activity were in the current task I could use FLAG_ACTIVITY_CLEAR_TOP in the intent, but this is not my case.
View 1 Replies
View Related
May 11, 2010
I'm starting with Scala + Android (and using the sbt android plugin). I'm trying to wire a button action to a button without the activity implementing View.OnClickListener.
The button click fails at runtime because the method cannot be found. The document I'm working through says that I need only declare a public void method taking a View on the action, and use that method name in the layout.
What have I done wrong? MainActivity.scala package net.badgerhunt.hwa
import android.app.Activity
import android.os.Bundle
import android.widget.Button
import android.view.View
import java.util.Date. Code...
View 1 Replies
View Related
Jun 11, 2009
Is there a function that allows me to get the top most view (the root)?
View 2 Replies
View Related
Feb 17, 2012
So I have my main activity. It starts out adding a custom SurfaceView called DrawView as the content view with
DrawView drawview = new DrawView(parameters);
this.setContentView(drawview);
now my layout.main.xml is a layout with a video view which I am using to play my cutscenes. I am able to switch to this view by calling a method I made which switches the content view by
this.setContentView(R.layout.main);
which works fine when I am calling this method within the Activity. Only problem is I need to call this method from within DrawView! The method I made to switch to my cutscene is public and I do pass the Activity (named Draw) as a parameter of DrawView.
So when I do call this method from within DrawView my game freezes and will subsequently crash! however it works when method is called locally?
View 3 Replies
View Related
Nov 7, 2010
I have a custom view that draws to a canvas. I am trying to invoke changes to the canvas when the user pushes a button from the activity that this view is tied to. Currently, I am attempting to do this by calling a public method, called setNewDrawable, that I created inside the view.
The debugger is giving me different values for the view ID depending on whether I'm inside setNewDrawable or inside the Overridden onDraw method when I post an Invalidate.
For example the debugger variables show: (This - MyView id=830067720176) or (This - MyView id=830067712344) in setNewDrawable and onDraw respectively. This makes me think I basically have two copies of the object and I am essentially interacting with the wrong one.
How can I get information to my custom View in order to determine what it draws?
Here is the code I am running...
View 1 Replies
View Related
Mar 29, 2010
I need show ads in my application. Ads in my custom view must move from bottom of screen with animation. How can I add my view in bottom of screen?
View 2 Replies
View Related
May 13, 2010
The default behavior of an activity when BACK softkey is pressed is, GO BACK TO PREVIOUS ACTIVITY. If some the same activity is waiting for some response from server or some data updation is going on and then press BACK, I want to wait on the same screen till the current task is completely processed and then move out to the previous activity.
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options
View 12 Replies
View Related
Aug 8, 2010
I am using the following method in a new application I'm developing. There is a main activity, which instantiates different classes that extends RelativeLayout and I'm using setContentView to switch between the different modules of the application. I wonder if this is a good approach or necessarily I have to use different activities to the several screens the app haves.
View 1 Replies
View Related
Nov 16, 2009
I'd like to show a png or jpg I downloaded from the next in an image viewer intent, but can't get it to work.
Bitmap bmp = getImageBitmap(jpg);
String path = getFilesDir().getAbsolutePath() + "/test.png";
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
bmp.compress( CompressFormat.PNG, 100, fos );
fos.close();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
I know the bitmap is downloaded ok (use the same routine for supplying it my ImageView instances elsewhere in my app) - I think it wrote to file ok, I can see it on disk and the file size is correct. The intent is launched but an exception is thrown: then the new activity just sits there, blank. How does this work?
View 1 Replies
View Related
Feb 28, 2010
I like to know how can i clone a view object which is already there in the view hierarchy, so that it can be added to the same view hierarchy again.
View 1 Replies
View Related
Sep 16, 2010
Is there any simple way to close the current tab or single tab in androids?
I don't want to do clearing all tabs and adding the required tabs?
View 1 Replies
View Related
Aug 27, 2010
My app is comprised of a set of reusable Activities that other apps can reuse. For various reasons, I would like my Activities to be launched in context of the invoking Activity's process, instead of always being launched in my Activity's process (default behavior on Android). How can I achieve this?
View 1 Replies
View Related
Apr 27, 2010
How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity?
View 1 Replies
View Related
Nov 5, 2010
The default behavior from my observation is if current activity force closes Android tries to go to previous activity on stack How can I control this behavior? I want force close to close all activities
View 2 Replies
View Related
Jul 16, 2010
I used Toast to make notification, but it seems it will appear even its activity is not in the current screen and some other activity has been started.I want to check this situation, when the activity is not the current one, I'd not send the Toast notification. But how to do ?
View 1 Replies
View Related
Oct 27, 2010
I'm in the middle of implementing themes for my application right now, and everything's been going really smooth until as of late. I've been using the android:background="?thin_border" tag to provide a background for linearlayouts with items that I want visually grouped together. The problem I'm running into is when I try to use this tag in an xml with a custom class as one of the elements, and try to add this background tag.
I've got an xml file that looks generally like so:
CODE:.................
and the custom class has two constructors:
CODE:........
with some other functions that store values, manipulate the data, etc. The custom layout class is only ever called directly in the xml, and the xml is inflated like so:
CODE:...........
The problem I'm running into is that I'm getting these error messages:
CODE:.................
The error seems to be caused by the android:background="?thin_border" tag. If I remove it from the layout, it inflates fine, and the program continues on. As soon as I add it back in, I get these errors and the program stops.
View 2 Replies
View Related
May 1, 2010
I have following problem with my application: From my main activity ("activity 1"), there is a menu from which user can launch an action. This action will result in an Intent being received by a BroadcastReceiver, defined in my application. Finally, this BroadcastReceiver will start an activity ("activity 2") to deal with this intent.
The problem is that I have a "quit application" entry in my menu, and I can only finish() currently active activity. ie I am not able to finish "activity 1" from the menu of "activity 2". And I can't use startActivityForResult() as "activity 2" can't be started from "activity 1". Any suggestion would be much appreciated Thank you very much guys, regards.
View 4 Replies
View Related
Jan 21, 2009
I need to replace the current View (set by the activity.setContentView method) by an other.
View 10 Replies
View Related
Sep 28, 2009
I created an application which is asynchronously communicating with the server. When the application makes a server request a new dialog (activity) with "loading" notification is created. The main activity implements methods for handling server responses and I would like to close the foreground activity when the main activity receives the answer from the server.
View 1 Replies
View Related
Oct 2, 2009
startActivity() displays the new Activity on top of the current one. But how to display it underneath instead? BTW, I'm starting an Activity from another application, if that makes a difference.
View 5 Replies
View Related
Nov 24, 2009
how to apply clicking action on listview in android.
View 1 Replies
View Related
Jul 23, 2010
How to apply action listener on Image view.
View 1 Replies
View Related
Mar 12, 2009
When my application is running, a button is pressed.After my application processes this event, i want to continue to transfer this event to other applications. Is it possible? If yes, how to do that?
View 6 Replies
View Related
Feb 14, 2010
Can I receive a broadcast event in an activity? I've seen this done in broadcast receivers but not in an activity. In particular I would like to receive an event when a bluetooth device is found. ACTION_DISCOVERY_FINISHED.
Do I need to declare that in the activity intent filters? Should I be using permissions for that? How do I define the callback to handle that in the activity when i get receive the action?
View 2 Replies
View Related
Jul 15, 2010
Is there any way to close the activity the launched another activity? So if activity A starts activity B can activity B close activity A? I know there is the tag android:finishOnTaskLaunch="true" but i only want it to happen if a button is pressed so im looking for a method to do it.
View 10 Replies
View Related
Feb 28, 2010
I am trying to start a new activity from a menu action, as follows:
CODE:.............
The class exists, and has the OnCreate method over-ridden, but whenever I try to perform the action in the simulator I get an ActivityNotFoundException raised. I have looked through the documents and as far as I can read, I do not need to create an Intent in the manifest.xml for this to work.
View 3 Replies
View Related
Mar 5, 2010
I am trying to launch an activity by specifying only its action(custom) defined in its intent filter from an activity in other application. The activity to be launched is the main activity of its application thus have android.intent.action.MAIN & android.intent.category.LAUNCHER set as action and category in its intent filter. Now according to android doc on Intent and Intent Filter, i do not need to specify DEFAULT category at all in this case. But doing the same i am i am unable to launch the activity.
LogCat says, Activity could not be found...
Am i misinterpreting the text or is there something else missing...?
Code, used for calling the activity
CODE:.............
Definition of Activity being called in the manifest file
COE:....................
View 1 Replies
View Related
Nov 12, 2010
Can any one suggest some helpful links so that I can get free online tutorial?
View 1 Replies
View Related
Jul 29, 2010
Is it possible to add an activity on top of the current activity.
For example lets say i click a button, and then it adds a second activity to the current activity. And the second activity only covers a small place at the bottom of my current activity.
View 3 Replies
View Related