LocalServiceBinding.java

by qlimax » Thu, 17 Dec 2009 21:04:04 GMT


Sponsored Links
 Hi guys.

I'm writing an application that use a service to play an audio file

I'm watching the LocalService.java and LocalServiceBinding.java
from the API DEMO

In the api demo, the LocalService.java make a notification in the
status bar, in my case it plays mp3 and make a notification. But that
doesn't matter.


My problem is that when the user press the "Back Button" the service
must stay active.
I want have the same behaviour as  when i press the "Home Button"...


Any help is welcome :D

ps:sorry for my eng

--



LocalServiceBinding.java

by qlimax » Thu, 17 Dec 2009 22:15:55 GMT


 sorry... maybe solved without binding
but using startService/stopService

----maybe... requires tests :::)))----
bye




--


Sponsored Links


LocalServiceBinding.java

by G » Thu, 17 Dec 2009 23:03:08 GMT


 Hey I ran into this problem a while back and was pulling my hair out.
The fix is easy (and you're on the right track)

You can still call bindService, you just have to call startService
first. If the service is started via bindService, then it will live
and die with the activity that called it, but if you start it with
startService and THEN bind it with bindService, it should stay alive
indefinitely.





--



LocalServiceBinding.java

by qlimax » Fri, 18 Dec 2009 00:16:43 GMT


 Hi G,
thanks a lot for the explanation.
(souch thigs should be better documented...)

bye.






--



Other Threads

1. query about the usage of HttpsURLConnection

Hi all,

I am using HttpsURLConnection to post data to a web server.

Here is the function I wrote to get the result.  (see the code below)

Very strangely, when the function be first called in my program it
would very likely return -1; and then I re-call the function after the
first call, it would always work ok.

So I wonder if there is anything I am missing in the code that when
the function be firstly called, the missing party is be "initialized",
in that the followed call goes OK.

Could anyone give some hints on this?

Here is my code of the function:
=============

Public MyReturn executeHttpsGet(Context context, String url) {

                       ................
               try {
URL u = new URL(url);
HttpsURLConnection httpConnection;
httpConnection = (HttpsURLConnection)u.openConnection();


  httpConnection.setSSLSocketFactory(mSslContext.getSocketFactory());
httpConnection.setHostnameVerifier(mVerifier);
httpConnection.setDoInput(true);
httpConnection.setConnectTimeout(DEFAULTTIMEOUT);
httpConnection.setUseCaches(true);

 httpConnection.connect();
ret.code = httpConnection.getResponseCode();
Log.i(TAG, "ResponseCode: "+String.valueOf(ret.code));
 BufferedReader reader;
if (ret.code == 200) {
reader = new BufferedReader(new
InputStreamReader(httpConnection.getInputStream()));
} else {
reader = new BufferedReader(new
InputStreamReader(httpConnection.getErrorStream()));
}

String line;
ret.body = "";
while((line = reader.readLine())!= null) {
ret.body = ret.body + line;
}
ret.reader = new StringReader(ret.body);
PsLogUtil.appendMessage(context, TAG, "Responsebody: "+ret.body);
 httpConnection.disconnect();
}catch (Exception e) {
e.printStackTrace();
Log.e(TAG, ""+e.getMessage());
ret.body = "";
ret.code = -1;
}


return ret;
}

====================

Thanks very much for your kindly help.

Best

Hugo

-- 

2. Google Latitude JSON/KML feed - getting user ID

I'm using the Google Latitude to get location data for select users. What
I'm wondering is if it is possible to get additional information from the
user ids than is provided in the JSON feed? Because right now I am unable to
get the user id, how can I get user id by email address?

-- 

3. SQLite database question

4. "Scheduling restart of crashed service", but no call to onStart() follows

5. Help! Icon aplikasi ada 2 (double) di milestone

6. _data column in audio_meta table

7. GestureBuilder and Multiple Strokes