This runs in separate process.I am using remote aidl. i created a method bitmap and displaying image from service to activity. Now when service gets crash, how to display message that service been crashed and disable progress dialog in activity?
Activity.java
ServiceSync service;
private ServiceConnection sync_service_connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder iservice) {
sync_service = IDownloadBoundServiceSync.Stub.asInterface(iservice);
sync_bound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
sync_bound = false;
//this should be displayed in UI by cancelling progress dialog
Toast.makeText(getApplicationContext(), "Service crashed", Toast.LENGTH_SHORT)
.show();
}
};
public void buttonclick(View view) {
bindService(new Intent(context, ServiceSync.class), sync_service_connection, context.BIND_AUTO_CREATE);
Log.d(getClass().getSimpleName(), "Download with sync");
prog_diag = ProgressDialog.show(context, "Download", "Downloading..please wait!", true);
prog_diag.setCancelable(false);
if (sync_bound) {
(new Thread() {
@Override
public void run() {
try {
final Bitmap file_name=sync_service.getBitmapFromURL(url_box.getText().toString());
Log.d(getClass().getSimpleName(), "Received file name from Sync Service");
runOnUiThread(new Runnable() {
@Override
public void run() {
if(file_name!=null)
{
displaybitmap(file_name);
}
else
{
prog_diag.dismiss();
}
I am using bitmap method using aidl