calling activity from service

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

calling activity from service

Postby nbagade » Mon Jun 28, 2010 8:09 am

Hi All,
Can we call activity from service? if yes anyone knows block of code.

Thanks in advance.

Regards,
Narendra
nbagade
Experienced Developer
Experienced Developer
 
Posts: 58
Joined: Fri Nov 20, 2009 7:49 am
Location: India

Top

Re: calling activity from service

Postby kaasnake » Fri Jul 09, 2010 9:14 am

in manifest descript your activity
Code: Select all
      <activity android:name="MyActivity">
         <intent-filter>
            <action android:name="com.package.MY_DIALOG"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
         </intent-filter>
      </activity>

then call activity from service trough intent
Code: Select all
Intent i = new Intent("com.package.MY_DIALOG");
         i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(i);

thats all.
kaasnake
Freshman
Freshman
 
Posts: 2
Joined: Fri Jul 09, 2010 9:06 am

Re: calling activity from service

Postby limteckchai » Wed Jul 21, 2010 8:52 am

Interesting Code!!!!
Does Any one has any idea how this snippet can be put to practical use??
limteckchai
Experienced Developer
Experienced Developer
 
Posts: 92
Joined: Mon Jun 28, 2010 3:33 am

Re: calling activity from service

Postby pskink » Wed Jul 21, 2010 9:52 am

limteckchai wrote:Interesting Code!!!!
Does Any one has any idea how this snippet can be put to practical use??


yes, anyone who wrote at least one android app knows how to use these snippets

did you try to write any android app?
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Re: calling activity from service

Postby limteckchai » Thu Jul 22, 2010 7:54 am

Hi pskink,
I realise I asked a stupid question. Thanks !!! :(..
limteckchai
Experienced Developer
Experienced Developer
 
Posts: 92
Joined: Mon Jun 28, 2010 3:33 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 8 guests