Click here to Skip to main content
15,890,506 members
Home / Discussions / Android
   

Android

 
QuestionHow to create Game in android Pin
Member 104347979-Feb-14 4:40
professionalMember 104347979-Feb-14 4:40 
AnswerRe: How to create Game in android Pin
Richard MacCutchan9-Feb-14 6:09
mveRichard MacCutchan9-Feb-14 6:09 
AnswerRe: How to create Game in android Pin
Jubayer Ahmed9-Feb-14 21:51
professionalJubayer Ahmed9-Feb-14 21:51 
QuestionHow To create a Centralized Database In Android Pin
coderTOcode7-Feb-14 5:07
coderTOcode7-Feb-14 5:07 
AnswerRe: How To create a Centralized Database In Android Pin
Simon_Whale7-Feb-14 5:39
Simon_Whale7-Feb-14 5:39 
AnswerRe: How To create a Centralized Database In Android Pin
Jubayer Ahmed12-Feb-14 1:43
professionalJubayer Ahmed12-Feb-14 1:43 
Questionhow to send data from service class to main activity class Pin
mAzeem226-Feb-14 7:43
mAzeem226-Feb-14 7:43 
AnswerRe: how to send data from service class to main activity class Pin
nfsoft16-Feb-14 1:39
nfsoft16-Feb-14 1:39 
You should use and Handlers...
Not so easy to implement.
//ON SERVICE SIDE
public class YourService extends Service {
  public static final int SAY_HELLO = 1;  
  public static final int REPLY_HELLO = 2;  

  private int cnt = 0;

  class IncomingHandler extends Handler {
    @Override
    public void handleMessage(Message msg) {
      switch (msg.what) {
        case SAY_HELLO:
          msg.replyTo.send(Message.obtain(null, REPLY_HELLO, cnt++, 0));
        break;
      } 
    }  

  /**
   * Target we publish for clients to send messages to IncomingHandler.
   */
  final IncomingHandler mHandler = new IncomingHandler();
  final Messenger mMessenger = new Messenger(mHandler);

}


//ON CLIENT SIDE

...
final Messenger mMessenger = new Messenger(new IncomingHandler()); //You can do it... 
private Messenger mBoundService;


private ServiceConnection mConnection = new ServiceConnection() {
	    public void onServiceConnected(ComponentName className, IBinder service) {
	        mBoundService = new Messenger(service);
	        mIsBound = true;
	        try{
	        	Message msg = Message.obtain(null, 1);
	        	msg.replyTo = mMessenger;
	            mBoundService.send(msg);
	        } catch (RemoteException ex){
	        	ex.printStackTrace();
	        }
	    }

	    public void onServiceDisconnected(ComponentName className) {
	    	mBoundService = null;
	        Toast.makeText(context, "Connection GONE", Toast.LENGTH_SHORT).show();
	    }
	};
	

	public void doBindService() {
		Intent intent = new Intent("com.yourpackage.YourService");
		if (!context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE)) {
		    try { 
		        context.unbindService(mConnection);
		    } catch (Throwable t) {}
		    // Clean up 
		    return;
		}
	}

	public void doUnbindService() {
	    if (mIsBound) {
	    	Message msg = Message.obtain(null, MESSAGE_UNREGISTER_CLIENT);
	    	msg.replyTo = mMessenger; 
	    	try{
	    		 mBoundService.send(msg);
	    	 } catch (RemoteException ex){
		     }
	        context.unbindService(mConnection);
	        mIsBound = false;
	    }
	}


So Sry... Im not so good helping ppl. Just wanted to share this, becouse it has been hard for me to.
QuestionSerializable or parcelable Pin
Member 105762046-Feb-14 1:32
Member 105762046-Feb-14 1:32 
AnswerRe: Serializable or parcelable Pin
Serge Desmedt16-Feb-14 1:03
professionalSerge Desmedt16-Feb-14 1:03 
Questionsynchronization with time code Pin
Member 105546904-Feb-14 1:12
Member 105546904-Feb-14 1:12 
Questionandroid longitude and latitude Pin
SURAJIT UPADHYAY4-Feb-14 0:31
SURAJIT UPADHYAY4-Feb-14 0:31 
AnswerRe: android longitude and latitude Pin
Chris Quinn4-Feb-14 3:14
Chris Quinn4-Feb-14 3:14 
AnswerRe: android longitude and latitude Pin
Jubayer Ahmed12-Feb-14 18:17
professionalJubayer Ahmed12-Feb-14 18:17 
Questionandroid longitude and latitude Pin
SURAJIT UPADHYAY3-Feb-14 23:39
SURAJIT UPADHYAY3-Feb-14 23:39 
AnswerRe: android longitude and latitude Pin
thatraja4-Feb-14 3:01
professionalthatraja4-Feb-14 3:01 
QuestionApplication to start with Pin
agent_kruger31-Jan-14 4:08
professionalagent_kruger31-Jan-14 4:08 
AnswerRe: Application to start with Pin
Peter Leow31-Jan-14 4:41
professionalPeter Leow31-Jan-14 4:41 
AnswerRe: Application to start with Pin
thatraja4-Feb-14 3:02
professionalthatraja4-Feb-14 3:02 
QuestionHow to run App in background?? Pin
mAzeem2229-Jan-14 8:25
mAzeem2229-Jan-14 8:25 
AnswerRe: How to run App in background?? Pin
one_one13-Feb-14 20:57
one_one13-Feb-14 20:57 
Questiontime verifier Pin
Member 1055469027-Jan-14 23:09
Member 1055469027-Jan-14 23:09 
QuestionHow to use delay in for loop? Pin
chandan kumar24-Jan-14 0:08
chandan kumar24-Jan-14 0:08 
QuestionLooking for Cross platformers Pin
bryce23-Jan-14 16:46
bryce23-Jan-14 16:46 
AnswerRe: Looking for Cross platformers Pin
Ron Beyer23-Jan-14 17:34
professionalRon Beyer23-Jan-14 17:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.