Android :: Create A Single Class Which Can Be Parent For Every Type Of Activity?

Oct 7, 2010

I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App.

I have many of these different activities in my app, ~12 activities. I want each of them to have the methods which are in the parent class.

Right now, i have created 4 parent activity classes which are extended from a certain activity depending on their type(ListActivity, Activity, MapActivity, TabActivity)

I am creating a lot of redundant code - each of the 4 parent activities has almost identical code, in exception for what class activity it extends.

Here is an example that may clarify what my problem is:

I have an Activity: MenuScreen which extends BaseListActivity BaseListActivity extends ListActivity BaseListActivity contains methods and fields which i want all my activities to have access to I have another Activity: HomeScreen which extends BaseActivity BaseActivity extends Activity BaseActivity contains the same methods and fields which are in my other Base[<type>]Activity classes(such as BaseListActivity)

These methods/fields are copy-pasted to all my Base[<type>]Activity, and seems awfully redundant to me.

Can i create a master activity class which all types of Activity classes can use as its parent? if not, am i stuck with copy and pasting this code and feeling gross/dirty about it?

Android :: create a single class which can be parent for every type of Activity?


Android :: FinishFromChild And OnActivityResult Not Firing When Child Starts Activity Of Same Type As Parent

Jun 8, 2010

I have an application, which (for the sake of simplicity) has two types of activities - Overview and DetailView. The Overview activity shows a list of steps and allows the user to start a DetailView activity corresponding to the step chosen.

In the DetailView activity, the user can start another Overview, which shows different steps than the ones in the parent of the current DetailView.

In the Overview, DetailView is started by using startActivityForResult (). In the DetailView, when the user decides to start a second Overview, I call setResult () and finish () and then start the new Overview. In this scenario, onActivityResult () and finishFromChild () do not fire. Instead, they fire when the parent finishes (?).

Code from Overview:

CODE:....

Code from DetailView:

CODE:..........................

View 1 Replies View Related

Android : How Can I Create Type Of Rectangle By Using Rect Class?

Jul 25, 2009

I have got a problem. How can i create the following rectangle by using Rect class? I mean Diagonal Rectangle. Is it possible through Rect class?? if not then any other way?

View 4 Replies View Related

Android :: Create A Class Which Not Extended Activity?

Sep 23, 2010

How to create a class which not extended Activity & how can i use it class?

View 1 Replies View Related

Android :: OnClickListener Not Firing From Parent Class

Aug 17, 2010

A Follow up to this question: http://stackoverflow.com/questions/3488880/group-of-views-controls-on-multiple-screens

I have created a parent class and a child class that inherits from it. When I set the OnClickListener in the child class, the event fires when the button is clicked. When I move the set OnClickListener to the parent class, the event doesn't fire. I've got to be missing something obvious but I just don't see it.

CODE:............

Child Class:

CODE:.........................

View 2 Replies View Related

Android :: How To End Child Activity And Return To Parent Activity?

Jul 25, 2010

I have a main screen with buttons to launch other subactivities. I have to press back button each time to go back to the main screen of my application. How do I finish a child activity and automatically return from the caller?

View 5 Replies View Related

Android :: Activity Parent - Created Activity Returns A Nul ?

Apr 7, 2010

Can someone tell if why when starting an activity with startActivity(intent) , calling getParent() in onCreate() of the new created activity returns a nul ?

Also how could I obtain the parent of an activity created in such a way ? Can a reference of the activity below the current activity in the activity stack be obtained ?

View 2 Replies View Related

Android :: Communicating Between Receiver Class And An Activity Class

Jul 14, 2010

I'm just getting into Android development, and I have a question about communicating between a receiver class and an activity class. I'm very new to JAVA and Android so I hope I don't sound too stupid. I'm developing an application where I intercept an SMS message and then based on various elements of that SMS I might delete it once it's been saved to the inbox. I have a receiver class that intercepts the txt message, and I am also able to delete messages from my inbox with code in the activity class using a button at the moment. The problem I have is communicating between the receiver class and the activity class where the code to delete a message resides. I tried putting that code directly into the receiver class but as I'm sure most of you already know the BroadcastReceiver class doesn't seem to support what I need to delete messages. I've been searching for an answer to this for a while, but haven't been able to find anything. Honestly I'm not sure I know enough about JAVA and Android to even recognize a solution if I saw it.

View 2 Replies View Related

Android :: Access Application Class From Class Other Then Activity

Sep 8, 2010

I'm new to Java and android development. In my application I need data which is accessible for a few activities. I've read that a good solution is to use Application class for this. So I use it like this:

public class MyApplication extends Application {
private String str;
public String getStr(){
return str;
}
public void setStr(String s){
str = s;
}
}

and I can access this variable from activity like this:........................................

View 2 Replies View Related

Android :: Call Activity Class From Other Java Class?

Oct 8, 2010

I have just started android. I just want to know that how can i call activity class from other java class. i just want to pass class object to activity class.

public class GsonParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MagazineThread thread=new MagazineThread();
thread.start();
}
public GsonParser(JsonMagazineParser Obj)
{

}
}

and i am just doing like from other class. GsonParser obj=new GsonParser(this);passing obj to activity class.how can i achieve that.

View 1 Replies View Related

Android :: Create A New File Together With Missing Parent Directories

Jun 22, 2010

When using

file.createNewFile();

I get the following exception

java.io.IOException: Parent directory of file does not exist: /.../pkg/databases/mydb

I am wondering is there a createNewFile that creates the missing parent directories?

View 1 Replies View Related

Android : How To Create An ImageView That Fills Parent Height?

Nov 24, 2010

I have an ImageView that is defined in the following way.. Now after downloading a new bitmap I change the drawable. The image now appears in the top left corner of the ImageView. Is there a way to have the image fill up the whole height that is possible and then adjust the width of the view to enable scaling the image without changing the aspect ratio?

View 3 Replies View Related

Android :: BringtoFront The Parent Activity?

Sep 7, 2010

As we know, startActivityForResult() used to get a result for a task from parent activity. Here when we click the setResult(). It returns the result to the parent Activity.

Child Activity means it should maintain the persistent state. That is when the users clicks a button on the child activity. It do not finishes that activity and show the Parent Activity. And again i may go to the child activity from parent activity. If the child does not exists it starts a new child activity else it should show the existing child activity with persistent content.

Simply said, my parent Activity starts a new Child Activity. Now both Activities should be alive. How to call the Parent Activity without finishing the child Activity(in other words, How to BringtoFront the parent Activity)? For this scenario,

you can not use startActivity(). Because it creates a new Activity Instance. Not Existing Parent Activity
you can not use startActivityForResult(). Because it finishes the child Activity Instance.

View 2 Replies View Related

Android :: Android - Start New Intent But No Parent Class

Jun 28, 2010

I've a ListActivity with a ListView, onItemClick I start an Intent. Oncreate of this Intent I make a getParent but it's null. if I do this.isChild() it's false.
mPostList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent IntentDiscution = new Intent(parent.getContext(), EcrireMessage.class);
....
IntentDiscution.putExtras(objetbunble);
parentClass.startActivity(IntentDiscution);
}

View 3 Replies View Related

Android :: How To Create 3 Equally Wide TextView Which Fill Parent Across The Screen

May 11, 2010

How can I create 3 equally wide TextView which fill parent across the screen? I tried doing this, but the width of the TextView are different: it is 149, 89, 89.

CODE:...................

View 1 Replies View Related

Android :: Finish Parent Activity From Child?

Mar 30, 2010

My child activity X is called from Parent activity P through startActivity(intent). I want to close P when X called its finish() method. I override a method finishFromChild(Activity child) in P and called finish() in it. But this functions (finishFromChild(Activity child)) is not being called after X finish() Is it a known bug or I am missing some thing? I googled and also searched the groups but no help.

An alternative could be... using StartActivityForResult() and a "fake" onActivityResult, where I can finish the parent activity, but this way is quite bad, i think...

I prefer the first one, if it would work....

View 3 Replies View Related

Android :: Activity That Does Not Fill The Parent Screen

Dec 14, 2009

Any idea why this doesn't create an activity that looks like a popup instead of an activity that completely fills the screen?

CODE:.............

I assumed that I only needed to set the layout height and layout width to something other than "fill_parent", but it still shows up as a black screen that completely fills the screen.

Ultimately, I simply want to create a popup, but I do not want to use an AlertDialog. Is this possible?

View 2 Replies View Related

Android :: Parent And Child Activity OnCreate?

Jul 2, 2010

I have a parent activity, and a child activity that extends the parent activity. When the parent starts the child activity,

Which onCreate gets executed first? The child's or parent's?

There is a particular variable I am setting in the Child activity's onCreate method, and right now, it looks like it takes a while to get to the Child activity's onCreate, and so the methods in the Parent are reporting an empty variable. Whereas when I make the Parent sleep for a while, it reports the correct variable.

CODE:............

So, basically, even after the Parent starts the Child, it still returns "Parent Value", but when I have the thread sleep, it return "Child Value".

View 1 Replies View Related

Android : Use Data Passed From Parent Activity In A Sub?

Jun 28, 2010

When we want to pass data from an activity to a sub activity we use the is there any event handler that handles this?

View 1 Replies View Related

Android :: Want To Open New Child Activity In Parent LinearLayout

Nov 8, 2010

I want to open new child activity in the parent LinearLayout. Just similar like Tabs.

View 1 Replies View Related

Android :: Return Back To The Parent Activity From Subactivity

Jun 14, 2010

My application supports twitter and needs to open browser for OAuth. When the user clicks the Share on Twitter button, the main activity will create another subactivity (TwitterActivity) to handle twitter authentication issues. Here is a flow graph showing how activities are invoked currently. Main is short for MainActivity and Twit for Twitter Activity. startActivity() OAuth intent OAuth callback finish()Main ---------------> Twit ------------> Browser --------------> Twit --------> Browser As you may notice, after the TwitterActivity calls finish() to stop, it will now return back to MainActivity, but Browser instead. How can I make it return back to MainActivity?

View 2 Replies View Related

Android :: Picking A Contact And Returning To The Parent Activity

Jan 28, 2010

I wish to re-use the Contacts application in a way to enable the user to pick a contact and return it to the parent activity (my application's activity).

For achieving this, I want to inquire about the kind of Intent that will be needed to launch the contacts application.

Intent i = new Intent(Intent.ACTION_GET_CONTENT, ?); startActivityForResult(.....);

What should be the second argument here ?

In the deprecated Contacts API, I could use the following snippet, but not sure about ContactsContract:

Intent i= new Intent(Intent.ACTION_GET_CONTENT,People.CONTENT_URI); startActivityForResult(i, reqCode);

View 3 Replies View Related

Android :: Detect If View's Parent Activity Is Being Destroyed?

Jun 30, 2010

I want to do some cleanup in a view when the activity is being destroyed. Is there any way to get a callback in the View when the activity is being destroyed? I tried using onDetachedFromWindow, but I'm not sure whether it is correct thing to do.

View 1 Replies View Related

Android :: Detect If A View's Parent Activity Is Paused

Jun 20, 2010

In one of my Activities I have a ListView that displays a list of locations. For each list item I want a little arrow icon that points in the direction of the corresponding location. I implemented this icon by extending ImageView. This custom View has a listener that reacts to changes of the device's orientation by rotating the icon image accordingly. I register the listener in the onAttachedToWindow() method and unregister it in onDetachedFromWindow(). This kind of works but the problem is that onDetachedFromWindow() sometimes gets called only a long time after the containing Activity has paused. Also, the whole layout overall seems a little hacky. So my question is: Is there a proper way to unregister the listeners or would you implement this in a completely different way to begin with?

View 1 Replies View Related

Android : Lifetime Of Background Parent Activity After StartActivityForResult()?

Jul 19, 2010

Is there an exception in the lifetime rules for a parent activity that's in the background after invoking startActivityForResult()? From my understanding, in low memory scenarios, the background activities are killed before the foreground. Does this rule still apply even if the background activity started the foreground one for the purpose of obtaining some result?

In this case, I think it would make sense for the foreground child activity to get killed first or to equalize the lifetime of the parent and child.

View 5 Replies View Related

Android :: Way To Identify Phone Intent Type From Another Class?

Aug 18, 2010

I create an Intent in one class then it's returned to another class. I need to check the type of intent it is. I need to ensure it's not a specific class of intent.

View 1 Replies View Related

Android :: SingleInstance Of The Activity And Relay Information Back To Parent?

May 8, 2009

I basically have three activities X, Y, Z and I want only one instance of each but I want control over the navigation and I can't do that by putting all three activities in one task because of the stack structure.

Here is a scenario, from X I launch Y given a certain "id" which correspondence to specific data in the DB, Y inflates and populates it's views, then I go back to X and launch Y again with a different "id" in the intent, I don't want the overhead of launching the activity and inflating the views again, anyone know how to do this?

I tried using singleInstance, but the problem is that I can't send the result code back to an activity in a different task.

View 4 Replies View Related

Android :: Parent Activity Runs OnCreate Before OnActivityResult Is Called - Sometimes

Aug 5, 2010

The order is:

A: startActivityForResult( B ) B: <dostuff>, call finish() A: onCreate <---- what's this all about A: onActivityResult

This happens for a tiny minority of users. I havn't been able to reproduce or find any common elements. A is the launch activity.

CODE:..............

View 7 Replies View Related

Android : Forward Activity Result To Parent With SingleTop Launch Mode?

Jun 1, 2010

I have two activities: a MainListActivity, and a DetailViewActivity. DetailViewActivity is set with android:launchMode="singleTop".

When clicking an item in the "main list" activity, it launches the "detail view" activity via:

startActivityForResult(detailIntent, REQUEST_CODE_DETAIL);

If I then call setResult(RESULT_OK, resultData); and finish(); from within the Detail activity, that resultData is received by the "main list" activity's onActivityResult(..) method correctly.

However, if I implement a "see previous"/"see next" type of navigation within the Detail activity, and implement it using singleTop, that result no longer gets sent back to the initial activity:

Intent nextItemIntent = this.createIntent(nextId);
nextItemIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(nextItemIntent);
// at this point, my DetailActivity's onNewIntent() method is called, and the new data is loaded properly

But from here, when I call setResult(..) and finish(), my MainList activity never receives the new/updated result. Anyone know what I'm doing wrong?

View 1 Replies View Related

Android :: Want To Create Multiple Images In Single Image

Oct 12, 2010

i want to create a bitmap / image which has many images like "Collage" which has more then one images in a single picture. I have stored all my images in a grid view but now i want to create a single image from all those images. And even i want to make few images click able so what can be the road map to do this ? any sort of help / example will be helpful. search for a for collage image image in google . one can see what it is exactly.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved