Example usage for android.os RemoteException printStackTrace

List of usage examples for android.os RemoteException printStackTrace

Introduction

In this page you can find the example usage for android.os RemoteException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

public void contributeOneDollar() {
    new Thread(new Runnable() {
        public void run() {
            ArrayList skuList = new ArrayList();
            skuList.add(oneDollar);//from w  ww.j  a v  a2  s . com
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
            final Bundle skuDetails;
            try {

                skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus);

                int response = skuDetails.getInt("RESPONSE_CODE");
                if (response == 0) {

                    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");

                    for (String thisResponse : responseList) {
                        JSONObject object = new JSONObject(thisResponse);
                        String sku = object.getString("productId");
                        String price = object.getString("price");
                        if (sku.equals(oneDollar)) {
                            System.out.println("price " + price);
                            Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp",
                                    "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(),
                                    Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        }
                    }
                }
                //
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SendIntentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();

}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

public void contributeTwentyDollars() {
    new Thread(new Runnable() {
        public void run() {
            ArrayList skuList = new ArrayList();
            skuList.add(twentyDollars);/*from  w  w  w. j av a 2  s . co m*/
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
            final Bundle skuDetails;
            try {

                skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus);

                int response = skuDetails.getInt("RESPONSE_CODE");
                if (response == 0) {

                    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");

                    for (String thisResponse : responseList) {
                        JSONObject object = new JSONObject(thisResponse);
                        String sku = object.getString("productId");
                        String price = object.getString("price");
                        if (sku.equals(twentyDollars)) {
                            System.out.println("price " + price);
                            Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp",
                                    "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(),
                                    Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        }
                    }
                }
                //
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SendIntentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();

}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

public void contributeFiftyDollars() {
    new Thread(new Runnable() {
        public void run() {
            ArrayList skuList = new ArrayList();
            skuList.add(fiftyDollars);//from  w w w.jav  a 2 s .  c  om
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
            final Bundle skuDetails;
            try {

                skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus);

                int response = skuDetails.getInt("RESPONSE_CODE");
                if (response == 0) {

                    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");

                    for (String thisResponse : responseList) {
                        JSONObject object = new JSONObject(thisResponse);
                        String sku = object.getString("productId");
                        String price = object.getString("price");
                        if (sku.equals(fiftyDollars)) {
                            System.out.println("price " + price);
                            Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp",
                                    "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(),
                                    Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        }
                    }
                }
                //
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SendIntentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();

}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

public void contributetwoDollars() {
    new Thread(new Runnable() {
        public void run() {
            ArrayList skuList = new ArrayList();
            skuList.add(twoDollars);/*from   ww w  . j a va 2s  .c o  m*/
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
            final Bundle skuDetails;
            try {

                skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus);

                int response = skuDetails.getInt("RESPONSE_CODE");
                if (response == 0) {

                    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");

                    for (String thisResponse : responseList) {
                        JSONObject object = new JSONObject(thisResponse);
                        String sku = object.getString("productId");
                        String price = object.getString("price");
                        if (sku.equals(twoDollars)) {
                            System.out.println("price " + price);
                            Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp",
                                    "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(),
                                    Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        }
                    }
                }
                //
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SendIntentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();

}

From source file:pt.aptoide.backupapps.Aptoide.java

private void handleIncomingIntent(Intent incomingIntent) {
    if (incomingIntent.getData() != null) {
        AptoideLog.d(this, "received intent: " + incomingIntent.getDataString());
        if (incomingIntent.getType() != null && incomingIntent.getType().equals(Constants.MIMETYPE_MYAPP)) {
            AptoideLog.d(this, "received myapp: " + incomingIntent.getDataString());
            try {
                serviceDataCaller.callReceiveMyapp(incomingIntent.getDataString());
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }/*from  w  ww  . j  ava2s.  c  om*/
        } else if (incomingIntent.getScheme().equals(Constants.SCHEME_MARKET)
                || (incomingIntent.getScheme().equals(Constants.SCHEME_HTTPS)
                        && incomingIntent.getData().getHost().equals(Constants.HOST_MARKET))) {
            String query = incomingIntent.getData().getQuery().split("&")[0].split("=")[1];
            if (query.contains(":")) {
                query = query.split(":")[1];
            }
            AptoideLog.d(this, "received market query: " + query);
            if (!synchronizingInstalledApps.get()) {
                startSearch(query, false, null, false);
            } else {
                blockedSearchQuery = query;
            }
        }

        cleanAptoideIntent();
    }
}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1001) {
        int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        final String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
        new Thread(new Runnable() {
            public void run() {
                //Thread.sleep(5*1000);
                try {
                    Bundle ownedItems = mservice.getPurchases(3, getPackageName(), "inapp", null);
                    // Check response
                    int responseCode = ownedItems.getInt("RESPONSE_CODE");
                    if (responseCode != 0) {
                        throw new Exception("Error");
                    }//from w w  w  .j  a va2s  . c  om
                    // Get the list of purchased items
                    ArrayList<String> purchaseDataList = ownedItems
                            .getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                    for (String purchaseData : purchaseDataList) {
                        JSONObject o = new JSONObject(purchaseData);
                        String purchaseToken = o.optString("token", o.optString("purchaseToken"));
                        // Consume purchaseToken, handling any errors
                        mservice.consumePurchase(3, getPackageName(), purchaseToken);
                    }
                } catch (RemoteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }).start();
        if (resultCode == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                new Thread(new Runnable() {
                    public void run() {
                        try {
                            Bundle ownedItems = mservice.getPurchases(3, getPackageName(), "inapp", null);
                            // Check response
                            int responseCode = ownedItems.getInt("RESPONSE_CODE");
                            if (responseCode != 0) {
                                throw new Exception("Error");
                            }
                            // Get the list of purchased items
                            ArrayList<String> purchaseDataList = ownedItems
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                            for (String purchaseData : purchaseDataList) {
                                JSONObject o = new JSONObject(purchaseData);
                                String purchaseToken = o.optString("token", o.optString("purchaseToken"));
                                // Consume purchaseToken, handling any errors
                                mservice.consumePurchase(3, getPackageName(), purchaseToken);
                            }
                        } catch (RemoteException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }).start();

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    }
}

From source file:pt.aptoide.backupapps.Aptoide.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!isRunning) {

        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

        theme = new ContextThemeWrapper(this, R.style.DialogTheme);

        //         currentAppsList = EnumAppsLists.Backup;

        //         handlingMyapps = new ArrayList<ViewMyapp>();

        queuedFlipperChanges = new ArrayList<EnumAptoideInterfaceTasks>();

        //         swypeDetector = new GestureDetector(new SwypeDetector());
        //         swypeListener = new View.OnTouchListener() {
        //                           @Override
        //                           public boolean onTouch(View v, MotionEvent event) {
        //                              return swypeDetector.onTouchEvent(event);
        //                           }
        //                        };
        //         swyping = new AtomicBoolean(false);
        //         swypeDelayHandler = new Handler();

        synchronizingInstalledApps = new AtomicBoolean(false);
        loadingRepos = new AtomicBoolean(false);
        //         resettingFlipper = new AtomicBoolean(false);
        highPriority = new AtomicBoolean(true);

        makeSureServiceDataIsRunning();/*from   w w  w.j  av a 2  s .  c  om*/

        isRunning = true;

        setContentView(R.layout.aptoide);

        //         searchView = (ImageView) findViewById(R.id.search_button);
        //         searchView.setOnTouchListener(new SearchClickListener());

        //         previousViewArrow = (ImageView) findViewById(R.id.previous);
        //         previousViewArrow.setOnClickListener(new OnPreviousClickedListener());
        //         previousViewArrow.setVisibility(View.INVISIBLE);

        //         previousListTitle = (TextView) findViewById(R.id.previous_title);
        //         previousListTitle.setText(getString(R.string.available));
        //         previousListTitle.setOnClickListener(new OnPreviousClickedListener());
        //         previousListTitle.setVisibility(View.INVISIBLE);
        //         currentListTitle = (TextView) findViewById(R.id.current_title);
        //         currentListTitle.setText(getString(R.string.available));
        //         currentListTitle.setClickable(false);
        //         nextListTitle = (TextView) findViewById(R.id.next_title);
        //         nextListTitle.setText(getString(R.string.installed));
        //         nextListTitle.setOnClickListener(new OnNextClickedListener());

        //         nextViewArrow = (ImageView) findViewById(R.id.next);
        //         nextViewArrow.setOnClickListener(new OnNextClickedListener());

        //         View categoriesView = LinearLayout.inflate(this, R.layout.apps_list, appsListFlipper);
        View availableView = LinearLayout.inflate(this, R.layout.list_apps, appsListPager);
        View installedView = LinearLayout.inflate(this, R.layout.list_apps, appsListPager);
        //         View updatableView = LinearLayout.inflate(this, R.layout.list_apps, appsListFlipper);

        //         emptyCategoriesList = categoriesView.findViewById(android.R.id.empty);
        //         emptyCategoriesList.setVisibility(View.GONE);
        //         emptyAvailableAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper);
        emptyAvailableAppsList = availableView.findViewById(android.R.id.empty);
        emptyAvailableAppsList.setVisibility(View.GONE);
        emptyAvailableAppsList.setTag(EnumAppsLists.RESTORE);
        //         emptyInstalledAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper);
        emptyInstalledAppsList = installedView.findViewById(android.R.id.empty);
        emptyInstalledAppsList.setVisibility(View.GONE);
        emptyInstalledAppsList.setTag(EnumAppsLists.BACKUP);
        //         emptyUpdatableAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper);
        //         emptyUpdatableAppsList = updatableView.findViewById(android.R.id.empty);
        //         emptyUpdatableAppsList.setVisibility(View.GONE);
        //         emptyUpdatableAppsList.setTag(EnumAppsLists.Updates);

        //         loadingCategoriesList = categoriesView.findViewById(R.id.loading);
        //         loadingAvailableAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper);
        loadingAvailableAppsList = availableView.findViewById(R.id.loading);
        loadingAvailableAppsList.setTag(EnumAppsLists.RESTORE);
        loadingAppsTitle = loadingAvailableAppsList.findViewById(R.id.loading_title);
        loadingAppsTitleWaitingOnServer = loadingAvailableAppsList
                .findViewById(R.id.loading_title_waiting_on_server);
        loadingAvailableAppsUnknownProgress = (ProgressBar) loadingAvailableAppsList
                .findViewById(R.id.loading_bar);
        loadingAvailableAppsProgress = (ProgressBar) loadingAvailableAppsList
                .findViewById(R.id.loading_progress_bar);
        loadingAvailableAppsProgressCompletionTarget = new AtomicInteger(0);
        loadingAvailableAppsProgressCurrent = new AtomicInteger(0);
        //         loadingInstalledAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper);
        loadingInstalledAppsList = installedView.findViewById(R.id.loading);
        loadingInstalledAppsList.setTag(EnumAppsLists.BACKUP);
        //         loadingUpdatableAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper);
        //         loadingUpdatableAppsList = updatableView.findViewById(R.id.loading);
        //         loadingUpdatableAppsList.setTag(EnumAppsLists.Updates);

        //         categoriesListView = new ListView(this);
        //         categoriesListView = (ListView) categoriesView.findViewById(android.R.id.list);
        //         categoriesListView.setCacheColorHint(Color.TRANSPARENT);
        //         categoriesListView.setOnTouchListener(swypeListener);
        //         categoriesListView.setOnItemClickListener(this);
        //         categoriesListView.setTag(EnumAppsLists.Available);
        //         categoriesListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);

        //         availableAppsListView = new ListView(this);
        availableAppsListView = (ListView) availableView.findViewById(android.R.id.list);
        availableAppsListView.setCacheColorHint(Color.TRANSPARENT);
        //         availableAppsListView.setOnTouchListener(swypeListener);
        availableAppsListView.setOnItemClickListener(this);
        availableAppsListView.setTag(EnumAppsLists.RESTORE);
        availableAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
        //      appsListFlipper.addView(availableAppsList);

        //         installedAppsListView = new ListView(this);
        installedAppsListView = (ListView) installedView.findViewById(android.R.id.list);
        installedAppsListView.setCacheColorHint(Color.TRANSPARENT);
        //         installedAppsListView.setOnTouchListener(swypeListener);
        installedAppsListView.setOnItemClickListener(this);
        installedAppsListView.setTag(EnumAppsLists.BACKUP);
        installedAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
        //      appsListFlipper.addView(installedAppsList);

        //         updatableAppsListView = new ListView(this);
        //         updatableAppsListView = (ListView) updatableView.findViewById(android.R.id.list);
        //         updatableAppsListView.setCacheColorHint(Color.TRANSPARENT);
        //         updatableAppsListView.setOnTouchListener(swypeListener);
        //         updatableAppsListView.setOnItemClickListener(this);
        //         updatableAppsListView.setTag(EnumAppsLists.Updates);
        //         updatableAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
        //      appsListFlipper.addView(updatableAppsList);

        Button backup = (Button) installedView.findViewById(R.id.action);
        backup.setText(R.string.backup_selected_apps);
        backup.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("Aptoide-AppsBackup", "Clicked on backup");

                //               if(selectedVersion.getRepoUri() != null){
                //                  if(authenticationToken == null){
                //                     try {
                //                        authenticationToken = serviceDataCaller.callGetServerToken();
                //                     } catch (RemoteException e) {
                //                        // TODO Auto-generated catch block
                //                        e.printStackTrace();
                //                     }
                //                  }
                //                  if(authenticationToken == null){
                //                     Log.d("Aptoide-AppsBackup", "No login set");
                //                     DialogLogin loginComments = new DialogLogin(AppInfo.this, serviceDataCaller, DialogLogin.InvoqueNature.NO_CREDENTIALS_SET);
                //                     loginComments.setOnDismissListener(new OnDismissListener() {
                //                        @Override
                //                        public void onDismiss(DialogInterface dialog) {
                //                           addAppVersionComment();
                //                        }
                //                     });
                //                     loginComments.show();
                //                  }else{
                //                     addAppVersionComment();                  
                //                  }
                //               }
                try {
                    authenticationToken = serviceDataCaller.callGetServerToken();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }

                ViewListIds uploads = new ViewListIds();

                for (int i = 0; i < installedAdapter.getCount(); i++) {
                    if (((ViewDisplayApplicationBackup) installedAdapter.getItem(i)).isChecked()) {
                        uploads.add(installedAdapter.getItem(i).getAppHashid());
                    }
                }

                if (uploads.size() > 0) {
                    installedAdapter.unselectAll();
                    if (authenticationToken != null) {
                        Intent upload = new Intent(Aptoide.this, Upload.class);
                        upload.putIntegerArrayListExtra("uploads", uploads);
                        startActivity(upload);
                    } else {
                        AptoideLog.d(Aptoide.this, "can't backup with no server login configured");
                        //                  Toast.makeText(Aptoide.this, R.string.login_required, Toast.LENGTH_SHORT).show();
                        login(uploads, EnumAppsLists.BACKUP);
                    }
                }

            }
        });

        Button restore = (Button) availableView.findViewById(R.id.action);
        restore.setText(R.string.restore_selected_apps);
        restore.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Log.d("Aptoide-AppsBackup", "Clicked on restore");
                try {
                    anyReposInUse = serviceDataCaller.callAnyReposInUse();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }

                ViewListIds restores = new ViewListIds();
                ViewDisplayApplicationBackup app;
                for (int i = 0; i < availableAdapter.getCount(); i++) {
                    app = ((ViewDisplayApplicationBackup) availableAdapter.getItem(i));
                    if (app.isChecked()) {
                        restores.add(availableAdapter.getItem(i).getAppHashid());
                        Toast.makeText(Aptoide.this,
                                getString(R.string.restoring_app, availableAdapter.getItem(i).getAppName()),
                                Toast.LENGTH_SHORT).show();
                    }
                }

                availableAdapter.unselectAll();

                if (anyReposInUse) {
                    for (Integer appHashid : restores) {
                        try {
                            serviceDataCaller.callInstallApp(appHashid);
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    AptoideLog.d(Aptoide.this, "can't restore with no repo configured");
                    //                  Toast.makeText(Aptoide.this, R.string.login_required, Toast.LENGTH_SHORT).show();
                    login(restores, EnumAppsLists.RESTORE);
                }
            }
        });

        ArrayList<View> pages = new ArrayList<View>();
        pages.add(installedView);
        pages.add(availableView);

        appsListPager = (ViewPager) findViewById(R.id.list_pager);
        ViewPagerAdapter pagerAdapter = new ViewPagerAdapter(pages);
        appsListPager.setAdapter(pagerAdapter);

        pageIndicator = (FixedTabsView) findViewById(R.id.indicator);
        pageIndicatorAdapter = new FixedTabsAdapter(this);
        pageIndicator.setAdapter(pageIndicatorAdapter);
        pageIndicator.setViewPager(appsListPager);

        //         appsListFlipper.addView(loadingAvailableAppsList);
        //         appsListFlipper.addView(loadingInstalledAppsList);
        //         appsListFlipper.addView(loadingUpdatableAppsList);
        //         appsListPager.addView(availableView);
        //         appsListPager.addView(installedView);
        //         appsListFlipper.addView(updatableView);
    }
}

From source file:pt.aptoide.backupapps.Aptoide.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    EnumOptionsMenu menuEntry = EnumOptionsMenu.reverseOrdinal(item.getItemId());
    Log.d("Aptoide-OptionsMenu", "menuOption: " + menuEntry + " itemid: " + item.getItemId());
    switch (menuEntry) {
    //         case MANAGE_REPO:
    //            availableAdapter.sleep();
    //            Intent manageRepo = new Intent(this, ManageRepos.class);
    //            startActivity(manageRepo);
    //            return true;

    case UNINSTALL:
        try {//from  ww  w  .  j  a v  a 2  s. c o m
            serviceDataCaller.callUninstallApps(installedAdapter.getSelectedIds());
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;

    case DELETE:
        //TODO improve listIds as an extended parcelable array ;) then use it as a carrier for checked hashids list
        return true;

    case DISPLAY_OPTIONS:
        if (!loadingRepos.get()) {
            //TODO refactor extract dialog management class
            LayoutInflater displayOptionsInflater = LayoutInflater.from(this);
            View displayOptions = displayOptionsInflater.inflate(R.layout.dialog_display_options, null);
            Builder dialogBuilder = new AlertDialog.Builder(theme).setView(displayOptions);
            final AlertDialog sortDialog = dialogBuilder.create();
            sortDialog.setIcon(android.R.drawable.ic_menu_sort_by_size);
            sortDialog.setTitle(getString(R.string.display_options));

            // ***********************************************************
            // Categories
            //               final RadioButton byCategory = (RadioButton) displayOptions.findViewById(R.id.by_category);
            //               final RadioButton byAll = (RadioButton) displayOptions.findViewById(R.id.by_all);
            //               if(availableByCategory){
            //                  byCategory.setChecked(true);
            //               }else{
            //                  byAll.setChecked(true);
            //               }
            //   
            //               final View spacer = displayOptions.findViewById(R.id.spacer);
            //               
            //               if(currentAppsList != EnumAppsLists.Available){
            //                  spacer.setVisibility(View.GONE);
            //                  ((RadioGroup) displayOptions.findViewById(R.id.group_show)).setVisibility(View.GONE);
            //               }

            // ***********************************************************
            // Sorting            
            final View group_sort = displayOptions.findViewById(R.id.group_sort);
            final RadioButton byAlphabetic = (RadioButton) displayOptions.findViewById(R.id.by_alphabetic);
            final RadioButton byFreshness = (RadioButton) displayOptions.findViewById(R.id.by_freshness);
            final RadioButton bySize = (RadioButton) displayOptions.findViewById(R.id.by_size);

            //               spacer.setVisibility(View.VISIBLE);
            group_sort.setVisibility(View.VISIBLE);
            switch (appsSortingPolicy) {
            case ALPHABETIC:
                byAlphabetic.setChecked(true);
                break;

            case FRESHNESS:
                byFreshness.setChecked(true);
                break;

            case SIZE:
                bySize.setChecked(true);
                break;

            default:
                break;
            }

            // ***********************************************************

            final CheckBox showSystemApps = (CheckBox) displayOptions.findViewById(R.id.show_system_apps);
            boolean showSystemAppsState = false;
            try {
                showSystemAppsState = serviceDataCaller.callGetShowSystemApps();
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            showSystemApps.setChecked(showSystemAppsState);
            final boolean storedShowSystemAppsState = showSystemAppsState;

            sortDialog.setButton(getString(R.string.done), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    //                     boolean byCategoryChanged = false;
                    EnumAppsSorting newSortingPolicy = null;

                    //                     if(byCategory.isChecked() != availableByCategory){
                    //                        byCategoryChanged = true;
                    //                        availableByCategory = byCategory.isChecked();
                    //                        setAvailableListBy(availableByCategory);
                    //                     }

                    if (showSystemApps.isChecked() != storedShowSystemAppsState) {
                        setShowSystemApps(showSystemApps.isChecked());
                    }

                    if (byAlphabetic.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.ALPHABETIC;
                    } else if (byFreshness.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.FRESHNESS;
                    } else if (bySize.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.SIZE;
                    }
                    if (newSortingPolicy != null && newSortingPolicy != appsSortingPolicy) {
                        //                        availableAdapter.sleep();
                        appsSortingPolicy = newSortingPolicy;
                        setAppsSortingPolicy(appsSortingPolicy);
                    }

                    //                     if(byCategoryChanged){
                    //                        if(availableByCategory){
                    //                           availableAdapter.sleep();
                    //                           categoriesAdapter.resetDisplayCategories();
                    //                        }else{
                    //                           availableAdapter.resetDisplay(null);                        
                    //                        }
                    //                     }
                    sortDialog.dismiss();
                }
            });

            sortDialog.show();
        } else {
            Toast.makeText(Aptoide.this, getString(R.string.option_not_available_while_updating_repos),
                    Toast.LENGTH_SHORT).show();
        }
        return true;

    //         case SEARCH_MENU:
    //            onSearchRequested();
    //            return true;

    case UN_SELECT_ALL:
        switch (currentAppsList) {
        case RESTORE:
            if (availableAdapter.isDynamic()) {
                Toast.makeText(Aptoide.this, getString(R.string.too_many_apps_to_select_at_once),
                        Toast.LENGTH_SHORT).show();
                return true;
            }
            availableAdapter.toggleSelectAll();
            break;

        case BACKUP:
            installedAdapter.toggleSelectAll();
            break;

        default:
            break;
        }
        return true;

    case ABOUT:
        LayoutInflater aboutInflater = LayoutInflater.from(this);
        View about = aboutInflater.inflate(R.layout.about, null);
        TextView info = (TextView) about.findViewById(R.id.credits);
        info.setText(getString(R.string.credits, versionName));
        Builder aboutCreator = new AlertDialog.Builder(theme).setView(about);
        final AlertDialog aboutDialog = aboutCreator.create();
        aboutDialog.setIcon(R.drawable.icon);
        aboutDialog.setTitle(R.string.self_name);
        //            aboutDialog.setButton(getText(R.string.changelog), new DialogInterface.OnClickListener() {
        //               public void onClick(DialogInterface dialog, int   whichButton) {
        //                  Uri uri = Uri.parse(getString(R.string.changelog_url));
        //                  startActivity(new Intent( Intent.ACTION_VIEW, uri));
        //               }
        //            });
        aboutDialog.show();
        return true;

    case SETTINGS:
        //            availableAdapter.sleep();
        Intent settings = new Intent(this, Settings.class);
        startActivity(settings);
        return true;

    case LOGIN:
        //            boolean insertingRepo = false;
        //            try {
        //               insertingRepo = serviceDataCaller.callIsInsertingRepo();
        //            } catch (RemoteException e1) {
        //               // TODO Auto-generated catch block
        //               e1.printStackTrace();
        //            }
        //            if(insertingRepo){
        //               AptoideLog.d(Aptoide.this, getString(R.string.updating_repo_please_wait));
        //               Toast.makeText(getApplicationContext(), getResources().getString(R.string.updating_repo_please_wait), Toast.LENGTH_SHORT).show();
        //            }
        //            else{
        Log.d("Aptoide-Settings", "clicked set server login");
        String token = null;
        try {
            token = serviceDataCaller.callGetServerToken();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (token == null) {
            Log.d("Aptoide-Settings", "No login set");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.NO_CREDENTIALS_SET.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.NO_CREDENTIALS_SET);
            //               loginComments.setOnDismissListener(new OnDismissListener() {
            //                  @Override
            //                  public void onDismiss(DialogInterface dialog) {
            //                     addAppVersionComment();
            //                  }
            //               });
            //               dialogLogin.show();
        } else {
            Log.d("Aptoide-Settings", "Login edit");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.OVERRIDE_CREDENTIALS.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.OVERRIDE_CREDENTIALS);
            //               Toast.makeText(Settings.this, "Login already set", Toast.LENGTH_SHORT).show();
            //               dialogLogin.show();
        }
        //            }
        return true;

    case FOLLOW:
        new DialogFollowOnSocialNets(this, serviceDataCaller).show();
        return true;

    //         case SCHEDULED_DOWNLOADS:
    //            availableAdapter.sleep();
    //            Intent manageScheduled = new Intent(this, ManageScheduled.class);
    //            startActivity(manageScheduled);
    //            return true;

    //         case UPDATE_ALL:
    //            if(!loadingRepos.get()){
    //               AptoideLog.d(this, "Update all");
    //               try {
    //                  serviceDataCaller.callUpdateAll();
    //               } catch (RemoteException e) {
    //                  // TODO Auto-generated catch block
    //                  e.printStackTrace();
    //               }
    //            }else{
    //               Toast.makeText(Aptoide.this, "Option not available while updating stores!", Toast.LENGTH_SHORT).show();
    //            }
    //            return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void unsetCallbackListener() {
    try {//  w ww. j a v  a  2 s. c  om
        mSvcServer.removeCallBack(mSvcClientCallback);
    } catch (RemoteException e) {
        e.printStackTrace();
        mGlblParms.util.addLogMsg("E", "unsetCallbackListener error :" + e.toString());
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private String[] getActiveTaskList() {
    String[] atl = null;/*from   w  w w  .  ja  va 2  s  .  com*/
    //      String[] all_task=null;
    try {
        atl = mSvcServer.aidlGetActiveTaskList();
        //         all_task=svcServer.aidlGetTaskList();
    } catch (RemoteException e) {
        e.printStackTrace();
        mGlblParms.util.addLogMsg("E", "aidlGetActiveTaskList error :" + e.toString());
    }
    return atl;
}