[Solved] Problem with IntentReceiver

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

Postby plusminus » Thu Feb 21, 2008 4:15 pm

Hello sasuke,

sasuke wrote:omg.... :oops: :oops:
so silly..... how could i do that... :lol: :lol:

Just remembering the time I wasted for searching such bugs, like overriding reDraw instead of rePaint and stuff liek that ^^
sasuke wrote:what's the difference : mainApp.this.mv.post and mv.post (without mainApp.this) ? optimization?

Differences are just textual. Imagine things get a lot bigger and you didn't write the code yourself, then it is much easier to see: "Ah, he's using the this-pointer of the outer class, because he is referring to a field in the outer class.".

sasuke wrote:nb: so, that's the picture of our great admin? 8)

8) Found no better picture 8)

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 sasuke » Fri Feb 22, 2008 11:23 am

um.. how to create an instance of myView class inside the intent receiver?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class myReceiver extends IntentReceiver{
  3.  
  4.         static final String ACTION = "myApp.android.intent.action.SEND_DATA";
  5.  
  6.         //private myView mv = new myView(new Context());
  7.  
  8.         public void onReceiveIntent(Context context, Intent intent) {
  9.  
  10.         if (intent.getAction().equals(ACTION)) {
  11.  
  12.                 //myReceiver.this.mv.post(myReceiver.this.mv.mUpdateTimeTask)
  13.  
  14.         }
  15.  
  16.     }
  17.  
  18. }
  19.  
  20.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


the listing for myView class is same as before...

regards,
sasuke
sasuke
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Fri Nov 30, 2007 1:25 pm

Postby plusminus » Fri Feb 22, 2008 10:21 pm

Hello sasuke,

are you sure you want to create a View in the IntentReceiver, because IntentReceiver cannot display things as Activities do.

Maybe explain, what you want to receive there and why you want to create your View inside there.

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 sasuke » Sat Feb 23, 2008 1:28 am

Hello plusminus,

I've mentioned it in my first post here (also in the picture too).. The IntentReceiver listen for the incoming msg from GTalkService, once it received, for example : "player 1 moved up", the IntentReceiver then redraw the player 1 position in it's device..

regards,
sasuke
sasuke
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Fri Nov 30, 2007 1:25 pm

Postby plusminus » Sat Feb 23, 2008 11:56 am

Hello sasuke,

was late last night :roll:

So the Game is kind of "live" and the Activity is always in foreground, right :?:

Then this is a pretty simple solution. Just place it i.e. in onCreate(..):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 registerReceiver(new IntentReceiver(){
  2.  
  3.                         @Override
  4.  
  5.                         public void onReceiveIntent(Context arg0, Intent arg1) {
  6.  
  7.                                 MainApp.this.mv.post(MainApp.this.mv.mUpdateTimeTask);
  8.  
  9.                         }
  10.  
  11.                 }, new IntentFilter("my_intent_action"));
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


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 sasuke » Sun Feb 24, 2008 6:40 am

Big thanks plusminus :D :D

it works now..

plusminus wrote:So the Game is kind of "live" and the Activity is always in foreground, right :?:


yup.... :P

one last question :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. new IntentFilter("my_intent_action")
  2.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


the string "my_intent_action", is there any rule to define it? like it must followed by" .android.intent.action." ??
mine : "myApp.android.intent.action.SEND_DATA"

regards,
sasuke
sasuke
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Fri Nov 30, 2007 1:25 pm

Top

Postby plusminus » Sun Feb 24, 2008 9:41 pm

Hello sasuke,

I don't think there is a rule, because as far as I know it is just String-comparison.

So yes, why not using your package-declaration :)

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
Previous

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 18 guests