List of usage examples for android.app.backup BackupManager dataChanged
public void dataChanged()
From source file:com.andrada.sitracker.ui.HomeActivity.java
private void scheduleBackup() { if (this.backUpTask != null) { this.backUpTask.cancel(); }/*from w ww . j a v a 2 s. co m*/ this.backUpTask = new TimerTask() { @Override public void run() { BackupManager bm = new BackupManager(getApplicationContext()); bm.dataChanged(); } }; backUpTimer.schedule(this.backUpTask, BACK_UP_DELAY); }
From source file:com.zns.comicdroid.activity.Comics.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menu_edit: if (mViewType == VIEWTYPE_GROUP) { GroupDialogFragment dialogGroup = GroupDialogFragment.newInstance(mGroupId, mCurrentGroup.getName(), mCurrentGroup.getTotalBookCount()); dialogGroup.show(getSupportFragmentManager(), "GROUPDIALOG"); } else {//from ww w. ja va2 s . c om RenameDialogFragment dialogRename = new RenameDialogFragment(); dialogRename.setName(mHeading); dialogRename.show(getSupportFragmentManager(), "RENAMEDIALOG"); } return true; case R.id.menu_delete: new AlertDialog.Builder(this).setTitle(R.string.group_delete_title) .setMultiChoiceItems(new String[] { getString(R.string.group_delete_alt) }, null, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface arg0, int pos, boolean checked) { mDeleteComics = checked; } }) .setPositiveButton(R.string.common_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { getDBHelper().deleteGroup(mGroupId, mDeleteComics); //Backup BackupManager m = new BackupManager(Comics.this); m.dataChanged(); //Back to start Intent intent2 = new Intent(Comics.this, Start.class); startActivity(intent2); finish(); } }).setNegativeButton(R.string.common_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); return true; case R.id.menu_editall: Intent intent = new Intent(this, Edit.class); int[] ids = mAdapter.getComicIds(); intent.putExtra(Edit.INTENT_COMIC_IDS, ids); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:io.coldstart.android.TrapListActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.e("onActivityResult", "requestCode" + requestCode + " / resultCode" + resultCode); //Check what the result was from the Settings Activity switch (requestCode) { case DISPLAY_SETTINGS: { BackupManager bm = new BackupManager(this); bm.dataChanged(); ((Thread) new Thread() { public void run() { try { API api = new API(); boolean updateTest = api.updateAccountSettings(securityID, settings.getBoolean("allowBundling", false), settings.getString("bundleDelay", "30")); } catch (Exception e) { e.printStackTrace(); }//from ww w . j a v a 2s .co m } }).start(); } break; //TODO remove as the onResume of the fragment handles the refresh case LAUNCHDETAILACTIVITY: { if (resultCode == TrapDetailFragment.ARG_QUITONDELETE) { /*Intent broadcast = new Intent(); broadcast.setAction(API.BROADCAST_ACTION); sendBroadcast(broadcast);*/ } } break; } }
From source file:com.zns.comicdroid.activity.Edit.java
private void UpdateComics() { final ContentValues values = new ContentValues(); final DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(this); String title = mEtTitle.getText().toString().trim(); if (title.toLowerCase(Locale.ENGLISH).startsWith("the ")) { title = title.substring(4) + ", The"; }//from w w w . j av a2 s . c om if (mComics != null && mComics.size() > 1) { if (!isEmpty(mEtTitle)) values.put("Title", title); if (!isEmpty(mEtSubtitle)) values.put("SubTitle", mEtSubtitle.getText().toString()); if (!isEmpty(mEtAuthor)) values.put("Author", mEtAuthor.getText().toString()); if (!isEmpty(mEtIllustrator)) values.put("Illustrator", mEtIllustrator.getText().toString()); if (!isEmpty(mEtPublisher)) values.put("Publisher", mEtPublisher.getText().toString()); if (mSpGroup.getSelectedItemPosition() > 0) { Group g = (Group) mSpGroup.getSelectedItem(); values.put("GroupId", g.getId()); } } else { //Strings values.put("Title", title); values.put("SubTitle", mEtSubtitle.getText().toString()); values.put("Author", mEtAuthor.getText().toString()); values.put("Illustrator", mEtIllustrator.getText().toString()); values.put("Publisher", mEtPublisher.getText().toString()); values.put("Issues", mEtIssues.getText().toString()); //Integers if (!isEmpty(mEtIssue)) { if (isValidInt(mEtIssue.getText().toString())) { values.put("Issue", Integer.parseInt(mEtIssue.getText().toString())); } else { Toast.makeText(this, R.string.edit_issueerror, Toast.LENGTH_LONG).show(); return; } } else { values.putNull("Issue"); } if (!isEmpty(mEtPageCount)) { if (isValidInt(mEtPageCount.getText().toString())) { values.put("PageCount", Integer.parseInt(mEtPageCount.getText().toString())); } else { Toast.makeText(this, R.string.edit_pagecounterror, Toast.LENGTH_LONG).show(); return; } } else { values.putNull("PageCount"); } //Dates try { if (!isEmpty(mEtPublished)) { values.put("PublishDate", getDBHelper().GetDateStamp(mEtPublished.getText().toString(), dateFormat)); } else { values.putNull("PublishDate"); } if (!isEmpty(mEtAdded)) { values.put("AddedDate", getDBHelper().GetDateStamp(mEtAdded.getText().toString(), dateFormat)); } else { values.putNull("AddedDate"); } } catch (ParseException e) { Toast.makeText(this, getString(R.string.edit_dateerror) + " " + dateFormat.format(new Date()), Toast.LENGTH_LONG).show(); return; } //Image if (mNewImage != null) { values.put("ImageUrl", ""); values.put("Image", new File(mNewImage).getName()); } //Group if (mSpGroup.getSelectedItemPosition() > 0) { Group g = (Group) mSpGroup.getSelectedItem(); values.put("GroupId", g.getId()); } else { values.putNull("GroupId"); } } if (mComics != null) { //UPDATE StringBuilder sbWhere = new StringBuilder("_id IN ("); String[] ids = new String[mComics.size()]; int i = 0; for (Comic c : mComics) { sbWhere.append("?,"); ids[i] = Integer.toString(c.getId()); i++; } sbWhere.setLength(sbWhere.length() - 1); sbWhere.append(")"); getDBHelper().update("tblBooks", values, sbWhere.toString(), ids); } else { //INSERT if (!values.containsKey("AddedDate") || values.get("AddedDate") == null) { values.remove("AddedDate"); values.put("AddedDate", (int) (System.currentTimeMillis() / 1000L)); } long id = getDBHelper().insert("tblBooks", values); Comic comic = getDBHelper().getComic((int) id); if (comic != null) { mComics = new ArrayList<Comic>(); mComics.add(comic); } } //Backup BackupManager m = new BackupManager(this); m.dataChanged(); setResult(RESULT_OK); Toast.makeText(this, getResources().getString(R.string.edit_done), Toast.LENGTH_LONG).show(); }
From source file:com.rbsoftware.pfm.personalfinancemanager.MainActivity.java
/** * Request data backup for devices with API <23 */// w w w. j av a 2s .c o m private void requestBackup() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { BackupManager bm = new BackupManager(this); bm.dataChanged(); } }
From source file:net.networksaremadeofstring.rhybudd.RhybuddHome.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Forces our onResume() function to do a DB call rather than a full HTTP request just cos we returned //from one of our subscreens resumeOnResultPollAPI = false;/*from ww w. j av a 2 s . c o m*/ BackupManager bm = new BackupManager(this); //Check what the result was from the Settings Activity if (requestCode == 99) { //Refresh the settings settings = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = new Intent(this, ZenossPoller.class); intent.putExtra("settingsUpdate", true); startService(intent); bm.dataChanged(); } else if (requestCode == ZenossAPI.ACTIVITYRESULT_PUSHCONFIG) { if (null != data && data.hasExtra(ZenossAPI.PREFERENCE_PUSHKEY)) { doGCMRegistration(data.getStringExtra(ZenossAPI.PREFERENCE_PUSHKEY)); } } else { //In theory the Settings activity should perform validation and only finish() if the settings pass validation if (resultCode == 1) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("FirstRun", false); editor.commit(); //Also update our onResume helper bool although it should already be set firstRun = false; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "Additional settings and functionality can be found by pressing the action bar overflow (or pressing the menu button).\r\n" + "\r\nPlease note that this is app is still in Beta. If you experience issues please email;\r\nGareth@NetworksAreMadeOfString.co.uk") .setTitle("Welcome to Rhybudd!").setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finishStart(true); } }); AlertDialog welcomeDialog = builder.create(); try { welcomeDialog.show(); } catch (Exception e) { finishStart(true); } bm.dataChanged(); } else if (resultCode == 2) { Toast.makeText(RhybuddHome.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); finish(); } //Who knows what happened here - quit else { Toast.makeText(RhybuddHome.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); finish(); } } }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Forces our onResume() function to do a DB call rather than a full HTTP request just cos we returned //from one of our subscreens //resumeOnResultPollAPI = false; BackupManager bm = null; try {//from www. j a v a 2 s. co m bm = new BackupManager(this); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult BackupManager", e); } switch (requestCode) { case LAUNCHSETTINGS: { settings = PreferenceManager.getDefaultSharedPreferences(this); try { Intent intent = new Intent(this, ZenossPoller.class); intent.putExtra("settingsUpdate", true); startService(intent); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult startService", e); } try { bm.dataChanged(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult bm.dataChanged()", e); } //SyncAdapter stuff if (null != mAccount) { try { mResolver = getContentResolver(); Bundle bndle = new Bundle(); ContentResolver.addPeriodicSync(mAccount, AUTHORITY, bndle, 86400); ContentResolver.setSyncAutomatically(mAccount, AUTHORITY, settings.getBoolean("refreshCache", true)); /*bndle.putBoolean( ContentResolver.SYNC_EXTRAS_MANUAL, true); bndle.putBoolean( ContentResolver.SYNC_EXTRAS_EXPEDITED, true); Log.e("addPeriodicSync","Requesting a full sync!"); ContentResolver.requestSync(mAccount, AUTHORITY, bndle);*/ } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult LAUNCHSETTINGS", e); } } else { //Log.e("addPeriodicSync","mAccount was null"); } } break; case ZenossAPI.ACTIVITYRESULT_PUSHCONFIG: { try { GCMRegistrar.unregister(this); if (PreferenceManager.getDefaultSharedPreferences(ViewZenossEventsListActivity.this) .getBoolean(ZenossAPI.PREFERENCE_PUSH_ENABLED, false)) doGCMRegistration(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult ACTIVITYRESULT_PUSHCONFIG", e); } } break; default: { if (resultCode == 1) { try { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("FirstRun", false); editor.commit(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default", e); } //Also update our onResume helper bool although it should already be set firstRun = false; AlertDialog.Builder builder = null; AlertDialog welcomeDialog = null; try { builder = new AlertDialog.Builder(this); builder.setMessage( "Additional settings and functionality can be found by pressing the Action bar overflow.\r\n" + "\r\nIf you experience issues please email;\r\nGareth@DataSift.com before leaving negative reviews.") .setTitle("Welcome to Rhybudd!").setCancelable(true) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finishStart(); } }); welcomeDialog = builder.create(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default", e); } try { welcomeDialog.show(); } catch (Exception e) { finishStart(); BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "OnActivityResult welcomedialog", e); } try { bm.dataChanged(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default", e); } } else if (resultCode == 2) { try { Toast.makeText(ViewZenossEventsListActivity.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult resultcode 2", e); } finish(); } //Who knows what happened here - quit else { //Toast.makeText(ViewZenossEventsListActivity.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show(); //finish(); } } break; } }
From source file:com.zoffcc.applications.zanavi.Navit.java
@TargetApi(Build.VERSION_CODES.FROYO) @Override/*from w w w. j ava 2 s.c o m*/ public void onPause() { // if COMM stuff is running, stop it! ZANaviDebugReceiver.stop_me = true; // hide main progress bar ------------ if (Navit.progressbar_main_activity.getVisibility() == View.VISIBLE) { Navit.progressbar_main_activity.setProgress(0); Navit.progressbar_main_activity.setVisibility(View.GONE); } // hide main progress bar ------------ try { sensorManager.unregisterListener(lightSensorEventListener); } catch (Exception e) { } // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- // -- dump all callbacks -- try { if (p.PREF_enable_debug_functions) { Message msg99a = new Message(); Bundle b99a = new Bundle(); b99a.putInt("Callback", 100); msg99a.setData(b99a); N_NavitGraphics.callback_handler.sendMessage(msg99a); } } catch (Exception e) { } // -- dump all callbacks -- // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- try { if (!Navit.is_navigating) { if (p.PREF_enable_debug_write_gpx) { NavitVehicle.pos_recording_end(); } } } catch (Exception e) { } // ---- DEBUG ---- // ---- DEBUG ---- // ---- DEBUG ---- // System.out.println("@@ onPause @@"); Log.e("Navit", "OnPause"); try { setPrefs_zoomlevel(); } catch (Exception e) { e.printStackTrace(); } try { watchmem.stop_me(); } catch (Exception e) { e.printStackTrace(); } try { //watchmem.join(); } catch (Exception e) { e.printStackTrace(); } try { //Simulate.stop_me(); } catch (Exception e) { e.printStackTrace(); } try { //Simulate.join(); } catch (Exception e) { e.printStackTrace(); } Navit.show_mem_used(); // if (!Navit.is_navigating) // { // try // { // mTts.stop(); // } // catch (Exception e) // { // // } // // try // { // mTts.shutdown(); // } // catch (Exception e) // { // // } // // mTts = null; // } super.onPause(); // signal to backupmanager that data "is / could have" changed try { Class.forName("android.app.backup.BackupManager"); BackupManager b = (BackupManager) backupManager; b.dataChanged(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } turn_off_compass(); // System.out.println("XXNAV: onpause:001"); if (!Navit.is_navigating) { // System.out.println("XXNAV: onpause:002"); NavitVehicle.turn_off_all_providers(); NavitVehicle.turn_off_sat_status(); // System.out.println("XXNAV: onpause:003"); } // Log.e("Navit", "OnPause"); cwthr.NavitActivity2(-1); Navit.show_mem_used(); try { if (wl != null) { wl.release(); Log.e("Navit", "WakeLock: release 1"); } } catch (Exception e) { e.printStackTrace(); } try { if (wl_cpu != null) { if (wl_cpu.isHeld()) { wl_cpu.release(); Log.e("Navit", "WakeLock CPU: release 1"); } } } catch (Exception e) { e.printStackTrace(); } // glSurfaceView.onPause(); is_paused = true; }