Как указать в пользовательском интерфейсе, когда сервис был разбит Android

Это выполняется в отдельном процессе. Я использую удаленную помощь. Я создал метод растрового изображения и отображения изображения от службы к деятельности. Теперь, когда происходит сбой службы, как отобразить сообщение о сбое службы и отключить диалог прогресса в действии?

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();
                            }

Я использую растровый метод с помощью aidl

0 ответов

Другие вопросы по тегам