Hi, An update to my question here: 

I have some code that gets executed when the screen is on, but when I power 
off the screen, has some problems in execution(even after acquiring 
Wakelock globally). I have a service that acquired a wakelock and calls the 
activity - ExecuteScript with the following code:

ExecuteScript.java:

Intent intent = new Intent(this,ScriptActivity.class);
intent.putExtra("code",code);
intent.putExtra("type", type);  
startActivityForResult(intent,REQUEST_CODE); 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
 super.onActivityResult(requestCode, resultCode, data);Log.d(TAG,"The result 
code value inside onActivityResult() is: "+requestCode +resultCode);if 
(resultCode == RESULT_OK && requestCode == REQUEST_CODE) {           
Log.d(TAG,"ScriptActivity finished success!!"); }       

And in my ScriptActivity(that calls Service and performs an operation that 
takes 30 seconds). However, the onActivityResult() is not called in my 
case. I am not sure why this occurs. Please help me.

I have defined the setResult() inside handler.postDelayed() block. I have 
code like:

ScriptActivity.java

Intent serviceIntent = new Intent(this,ScriptService.class);
serviceIntent.putExtra("code",code);
serviceIntent.putExtra("type",type);
startService(serviceIntent);
handler.postDelayed(new Runnable(){public void run(){     
      Intent data = new Intent(ScriptActivity.this,ExecuteScript.class);
      data.putExtra("returnKey1", "You can write the file to the server "); 
      if(getParent()==null)   
      {
      setResult(Activity.RESULT_OK, data);
      Log.d(TAG,"Inside the if block");
      }
      else
      {
          getParent().setResult(Activity.RESULT_OK, data);   
          Log.d(TAG,"Inside the else block");
      }
      Log.d(TAG,"**After calling the method startActivityTwo here*****");
      finish();
      }},30000);





On Tuesday, February 5, 2013 2:25:45 PM UTC+2, a wrote:
>
> Hi,
>
> I am developing an application where a service S1 has a method that starts 
> an intent I. The intent I inturn calls service S2 using 
>
> startActivityForResult()
>
> and onActivityResult() defined in intent I returns a value. I want my app 
> to be executed even when the device is sleeping. Currently, I acquire the 
> wakelock and wifilock (as I have Wi-fi and sockets for communication) in 
> S1's onCreate() and release them in S1's onDestroy(). However, if intent I 
> is called, the execution stops till the screen is locked. Can anybody guide 
> where I have to acquire and release the locks? Or if I have to acquire a 
> global wake-lock for my app as specified in the link : 
> http://mobilecoder.wordpress.com/2010/02/15/global-wakelocks-for-dummies-like-me/
>
> Please let me know if you need more details.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to