problem in simple example of IntentReceiver

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

problem in simple example of IntentReceiver

Postby soniya » Tue Feb 19, 2008 7:35 pm

i use in xml file

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <activity android:name=".file1" android:label="file1">
  2.  
  3.           <intent-filter>
  4.  
  5.                 <action android:name="android.intent.action.MAIN" />
  6.  
  7.                 <category android:name="android.intent.category.LAUNCHER" />
  8.  
  9.             </intent-filter>
  10.  
  11.      </activity>
  12.  
  13.      
  14.  
  15.      <receiver android:name=".file2">
  16.  
  17.             <intent-filter>
  18.  
  19.                  <action android:name="android.intent.action.EDIT" />
  20.  
  21.                  <category android:name="android.intent.category.DEFAULT" />
  22.  
  23.             </intent-filter>
  24.  
  25.         </receiver>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


in Acitivity class
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.  
  3.         super.onCreate(icicle);
  4.  
  5.         setContentView(R.layout.main);
  6.  
  7. Intent i=new Intent(this,file2.class);
  8.  
  9.  startSubActivity(i,0);
  10.  
  11. }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and file2 class extend IntentRecevier

in code show error...how to call IntentRecevier class in activity class???how to solved??
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Postby plusminus » Tue Feb 19, 2008 8:36 pm

Hello soniya,

remember IntentReceivers have no GUI :!: and IntentReceiver != Activity :!:

Don't know what you are exactly trying to do, but you could define your own Intent:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected static final String MY_INTENT_BLA_BLA = new String("android.intent.action.MY_INTENT_BLA_BLA");
  2.  
  3. broadcastIntent(new Intent(MY_INTENT_BLA_BLA));
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


You'll should then to make your IntentReceiver listen to that Intent (in AndroidManifest.xml).

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 soniya » Wed Feb 20, 2008 10:44 am

thanks for reply......if in application detect alarm is active and no...
we use


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.    <uses-permission android:name="android.permission.FOTA_UPDATE" />
  2.  
  3.     <application android:icon="@drawable/icon">
  4.  
  5.    
  6.  
  7.         <activity android:name=".file" android:label="@string/app_name">
  8.  
  9.             <intent-filter>
  10.  
  11.                 <action android:name="android.intent.action.MAIN" />
  12.  
  13.                 <category android:name="android.intent.category.LAUNCHER" />
  14.  
  15.             </intent-filter>
  16.  
  17.         </activity>
  18.  
  19.         <receiver android:name=".file2">
  20.  
  21.          
  22.  
  23.             <intent-filter>
  24.  
  25.                     <action android:name="android.server.checkin.FOTA_RESTART" />
  26.  
  27.                       <category android:name="android.intent.category.DEFAULT" />
  28.  
  29.                  <category android:name="android.intent.category.HOME" />
  30.  
  31.             </intent-filter>
  32.  
  33.          
  34.  
  35.         </receiver>
  36.  
  37.     </application>
  38.  
  39. </manifest>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


and in IntentReceiver use
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onReceiveIntent(Context context, Intent intent) {
  2.  
  3.                  
  4.  
  5.                   if (intent.getAction().equals(ACTION1)) {
  6.  
  7.                           Log.i(LOG_TAG,"android.server.checkin.FOTA_RESTART");
  8.  
  9.                           Toast.makeText(context, "android.server.checkin.FOTA_RESTART", Toast.LENGTH_LONG).show();
  10.  
  11.                           Intent i=new Intent(context,file.class);
  12.  
  13.                           i.setLaunchFlags(Intent.FORWARD_RESULT_LAUNCH);
  14.  
  15.                           context.startActivity(i);
  16.  
  17.                   }
  18.  
  19.                  
  20.  
  21.            }  
  22.  
  23.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


but it not show any thing where is problem??? plz tel me
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Wed Feb 20, 2008 10:51 am

Did you ensure that the onReceiveIntent gets called :?:

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 soniya » Wed Feb 20, 2008 11:13 am

im not getting what u ask.....actually alarm is start in emulator to API Demo ...im detect that alram is start and no....am i doing right and wrong :?: ...is cannot display anything......
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Wed Feb 20, 2008 6:49 pm

Hello soniya,

I wanted to know, whether the Intent does not get fired or the Intent gets fired and nothing happens.

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

Top

Postby soniya » Thu Feb 21, 2008 7:15 am

onReceiveIntent is called but it's not show ...but why i don't know
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 9 guests