Calling methods of an Activity from a java class

Put your problem here if it does not fit any of the other categories.

Calling methods of an Activity from a java class

Postby manmath » Fri Feb 29, 2008 7:58 am

Hello,

I have a method defined in an activity and i want to call it from a simple java class which contains the activity object. how can i acheive this :?:

I have tried to finish an activty from a simple java class using the activity object , the activity is not destroyed but there are no errors :!:

What is the reason behind this :?:

Thanks in advance
Manmath
manmath
Junior Developer
Junior Developer
 
Posts: 18
Joined: Fri Feb 15, 2008 1:30 pm
Location: India

Top

Postby plusminus » Fri Feb 29, 2008 4:51 pm

Hello manmath,

I haven't tried .finish(), but calling normal methods works fine from another Class.
Maybe a security issue. Are you calling the function from the GUI-Thread :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby manmath » Mon Mar 03, 2008 7:14 am

Hi plusminus,

:arrow: Regarding Calling thread :
I am calling from other thread like connection thread or handler (not from GUI).

:arrow: I found some intresting behaviour of finish(): There are two ways to start an activity after finishing the previous one.
1. Call finish() then start new Activty.
2. Start the Activity and finsh() the previuos one after that in next statement.


I think case2 is prefered than case1. But Some times the Previous activity goes to pause state instead of destroyrd state. This is because new activity is started before finish() called.
This is behaviour is not consistent.

To avoid such situation (Case2), i am calling finish() again inside onPause() of previous activity.

Can you suggest some better solution for such scenario :?:

:arrow: What sort of security issues you are talking about ? Shall i add some permission in the manifest file ?
manmath
Junior Developer
Junior Developer
 
Posts: 18
Joined: Fri Feb 15, 2008 1:30 pm
Location: India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 34 guests