List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:com.android.launcher2.Launcher.java
/** * Sets the app market icon/*from www .ja v a 2 s . co m*/ */ private void updateAppMarketIcon() { final View marketButton = findViewById(R.id.market_button); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); if (activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME); marketButton.setVisibility(View.VISIBLE); } else { // We should hide and disable the view so that we don't try and restore the visibility // of it when we swap between drag & normal states from IconDropTarget subclasses. marketButton.setVisibility(View.GONE); marketButton.setEnabled(false); } }
From source file:com.android.soma.Launcher.java
/** * Sets the app market icon//w w w .j a v a2s. c o m */ private void updateAppMarketIcon() { if (!DISABLE_MARKET_BUTTON) { final View marketButton = findViewById(R.id.market_button); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); if (activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME); marketButton.setVisibility(View.VISIBLE); } else { // We should hide and disable the view so that we don't try and restore the visibility // of it when we swap between drag & normal states from IconDropTarget subclasses. marketButton.setVisibility(View.GONE); marketButton.setEnabled(false); } } }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void setUiDisabled() { util.addDebugMsg(1, "I", "setUiDisabled entered"); enableMainUi = false;//from ww w. j ava 2 s . co m setOnKeyCallBackListener(new CallBackListener() { public boolean onCallBack(Context c, Object o1, Object[] o2) { Intent in = new Intent(); in.setAction(Intent.ACTION_MAIN); in.addCategory(Intent.CATEGORY_HOME); startActivity(in); return true; } }); if (!mGp.syncTaskAdapter.isShowCheckBox()) setProfileContextButtonNormalMode(); else setProfileContextButtonSelectMode(); if (!mGp.syncHistoryAdapter.isShowCheckBox()) setHistoryContextButtonNormalMode(); else setHistoryContextButtonSelectMode(); refreshOptionMenu(); }
From source file:org.mozilla.gecko.BrowserApp.java
@Override protected void onNewIntent(Intent intent) { String action = intent.getAction(); final boolean isViewAction = Intent.ACTION_VIEW.equals(action); final boolean isBookmarkAction = GeckoApp.ACTION_HOMESCREEN_SHORTCUT.equals(action); final boolean isTabQueueAction = TabQueueHelper.LOAD_URLS_ACTION.equals(action); if (mInitialized && (isViewAction || isBookmarkAction)) { // Dismiss editing mode if the user is loading a URL from an external app. mBrowserToolbar.cancelEdit();// w w w .j av a2s .co m // Hide firstrun-pane if the user is loading a URL from an external app. hideFirstrunPager(); if (isBookmarkAction) { // GeckoApp.ACTION_HOMESCREEN_SHORTCUT means we're opening a bookmark that // was added to Android's homescreen. Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.HOMESCREEN); } } showTabQueuePromptIfApplicable(intent); super.onNewIntent(intent); if (AppConstants.MOZ_ANDROID_BEAM && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(uri)); } // Only solicit feedback when the app has been launched from the icon shortcut. if (GuestSession.NOTIFICATION_INTENT.equals(action)) { GuestSession.handleIntent(this, intent); } // If the user has clicked the tab queue notification then load the tabs. if (AppConstants.NIGHTLY_BUILD && AppConstants.MOZ_ANDROID_TAB_QUEUE && mInitialized && isTabQueueAction) { Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION, "tabqueue"); ThreadUtils.postToBackgroundThread(new Runnable() { @Override public void run() { openQueuedTabs(); } }); } if (!mInitialized || !Intent.ACTION_MAIN.equals(action)) { return; } // Check to see how many times the app has been launched. final String keyName = getPackageName() + ".feedback_launch_count"; final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads(); // Faster on main thread with an async apply(). try { SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE); int launchCount = settings.getInt(keyName, 0); if (launchCount < FEEDBACK_LAUNCH_COUNT) { // Increment the launch count and store the new value. launchCount++; settings.edit().putInt(keyName, launchCount).apply(); // If we've reached our magic number, show the feedback page. if (launchCount == FEEDBACK_LAUNCH_COUNT) { GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feedback:Show", null)); } } } finally { StrictMode.setThreadPolicy(savedPolicy); } }
From source file:com.android.launcher2.Workspace.java
void updateShortcuts(ArrayList<ApplicationInfo> apps) { ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers(); for (ShortcutAndWidgetContainer layout : childrenLayouts) { int childCount = layout.getChildCount(); for (int j = 0; j < childCount; j++) { final View view = layout.getChildAt(j); Object tag = view.getTag(); if (tag instanceof ShortcutInfo) { ShortcutInfo info = (ShortcutInfo) tag; // We need to check for ACTION_MAIN otherwise getComponent() might // return null for some shortcuts (for instance, for shortcuts to // web pages.) final Intent intent = info.intent; final ComponentName name = intent.getComponent(); if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) { final int appCount = apps.size(); for (int k = 0; k < appCount; k++) { ApplicationInfo app = apps.get(k); if (app.componentName.equals(name)) { BubbleTextView shortcut = (BubbleTextView) view; info.updateIcon(mIconCache); info.title = app.title.toString(); shortcut.applyFromShortcutInfo(info, mIconCache); }/* w w w . j a va2 s . c om*/ } } } } } }
From source file:com.fairphone.fplauncher3.Workspace.java
private void updateShortcutsAndWidgetsPerUser(ArrayList<AppInfo> apps, final UserHandleCompat user) { // Create a map of the apps to test against final HashMap<ComponentName, AppInfo> appsMap = new HashMap<ComponentName, AppInfo>(); final HashSet<String> pkgNames = new HashSet<String>(); for (AppInfo ai : apps) { appsMap.put(ai.componentName, ai); pkgNames.add(ai.componentName.getPackageName()); }// w w w. j a va2 s .c o m final HashSet<ComponentName> iconsToRemove = new HashSet<ComponentName>(); mapOverItems(MAP_RECURSE, new ItemOperator() { @Override public boolean evaluate(ItemInfo info, View v, View parent) { if (info instanceof ShortcutInfo && v instanceof BubbleTextView) { ShortcutInfo shortcutInfo = (ShortcutInfo) info; ComponentName cn = shortcutInfo.getTargetComponent(); AppInfo appInfo = appsMap.get(cn); if (user.equals(shortcutInfo.user) && cn != null && LauncherModel.isShortcutInfoUpdateable(info) && pkgNames.contains(cn.getPackageName())) { boolean promiseStateChanged = false; boolean infoUpdated = false; if (shortcutInfo.isPromise()) { if (shortcutInfo.hasStatusFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) { // Auto install icon PackageManager pm = getContext().getPackageManager(); ResolveInfo matched = pm .resolveActivity( new Intent(Intent.ACTION_MAIN).setComponent(cn) .addCategory(Intent.CATEGORY_LAUNCHER), PackageManager.MATCH_DEFAULT_ONLY); if (matched == null) { // Try to find the best match activity. Intent intent = pm.getLaunchIntentForPackage(cn.getPackageName()); if (intent != null) { cn = intent.getComponent(); appInfo = appsMap.get(cn); } if ((intent == null) || (appsMap == null)) { // Could not find a default activity. Remove this item. iconsToRemove.add(shortcutInfo.getTargetComponent()); // process next shortcut. return false; } shortcutInfo.promisedIntent = intent; } } // Restore the shortcut. shortcutInfo.intent = shortcutInfo.promisedIntent; shortcutInfo.promisedIntent = null; shortcutInfo.status &= ~ShortcutInfo.FLAG_RESTORED_ICON & ~ShortcutInfo.FLAG_AUTOINTALL_ICON & ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE; promiseStateChanged = true; infoUpdated = true; shortcutInfo.updateIcon(mIconCache); LauncherModel.updateItemInDatabase(getContext(), shortcutInfo); } if (appInfo != null) { shortcutInfo.updateIcon(mIconCache); shortcutInfo.title = appInfo.title.toString(); shortcutInfo.contentDescription = appInfo.contentDescription; infoUpdated = true; } if (infoUpdated) { BubbleTextView shortcut = (BubbleTextView) v; shortcut.applyFromShortcutInfo(shortcutInfo, mIconCache, true, promiseStateChanged); if (parent != null) { parent.invalidate(); } } } } // process all the shortcuts return false; } }); if (!iconsToRemove.isEmpty()) { removeItemsByComponentName(iconsToRemove, user); } if (user.equals(UserHandleCompat.myUserHandle())) { restorePendingWidgets(pkgNames); } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
/** * ADW: Home binding actions//from ww w . j av a2 s . co m */ public void fireHomeBinding(int bindingValue, int type) { // ADW: switch home button binding user selection if (mIsEditMode || mIsWidgetEditMode) return; switch (bindingValue) { case BIND_DEFAULT: dismissPreviews(); if (!mWorkspace.isDefaultScreenShowing()) { mWorkspace.moveToDefaultScreen(); } break; case BIND_HOME_PREVIEWS: if (!mWorkspace.isDefaultScreenShowing()) { dismissPreviews(); mWorkspace.moveToDefaultScreen(); } else { if (!showingPreviews) { showPreviews(mHandleView, 0, mWorkspace.mHomeScreens); } else { dismissPreviews(); } } break; case BIND_PREVIEWS: if (!showingPreviews) { showPreviews(mHandleView, 0, mWorkspace.mHomeScreens); } else { dismissPreviews(); } break; case BIND_APPS: dismissPreviews(); if (isAllAppsVisible()) { mRAB.setVisibility(View.VISIBLE); mLAB.setVisibility(View.VISIBLE); mHandleView.updateIcon(); closeDrawer(); } else { showAllApps(true, null); } break; case BIND_STATUSBAR: WindowManager.LayoutParams attrs = getWindow().getAttributes(); /* * if((attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == * WindowManager.LayoutParams.FLAG_FULLSCREEN){ //go non-full screen * fullScreen(false); }else{ //go full screen fullScreen(true); } */ // 290778 commented for Non full screen mode fullScreen(false); break; case BIND_NOTIFICATIONS: dismissPreviews(); showNotifications(); break; case BIND_HOME_NOTIFICATIONS: if (!mWorkspace.isDefaultScreenShowing()) { dismissPreviews(); mWorkspace.moveToDefaultScreen(); } else { dismissPreviews(); showNotifications(); } break; case BIND_DOCKBAR: dismissPreviews(); if (showDockBar) { if (mDockBar.isOpen()) { mDockBar.close(); } else { mDockBar.open(); } } break; case BIND_APP_LAUNCHER: // Launch or bring to front selected app // Get PackageName and ClassName of selected App String package_name = ""; String name = ""; switch (type) { case 1: package_name = PersonaAlmostNexusSettingsHelper.getHomeBindingAppToLaunchPackageName(this); name = PersonaAlmostNexusSettingsHelper.getHomeBindingAppToLaunchName(this); break; case 2: package_name = PersonaAlmostNexusSettingsHelper.getSwipeUpAppToLaunchPackageName(this); name = PersonaAlmostNexusSettingsHelper.getSwipeUpAppToLaunchName(this); break; case 3: package_name = PersonaAlmostNexusSettingsHelper.getSwipeDownAppToLaunchPackageName(this); name = PersonaAlmostNexusSettingsHelper.getSwipeDownAppToLaunchName(this); break; default: break; } // Create Intent to Launch App if (package_name != "" && name != "") { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); i.setComponent(new ComponentName(package_name, name)); try { startActivity(i); } catch (Exception e) { } } break; default: break; } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private void updateCounters(View view, String packageName, int counter, int color, int updateCounterFor) { Object tag = view.getTag();/* ww w .j a v a 2 s. c o m*/ //PersonaLog.d("personalauncher","------- view is ---- "+ view.toString()); if (tag != null) //PersonaLog.d("personalauncher","------- tag is ---- "+ tag.toString()); if (tag instanceof PersonaApplicationInfo) { PersonaApplicationInfo info = (PersonaApplicationInfo) tag; // We need to check for ACTION_MAIN otherwise getComponent() might // return null for some shortcuts (for instance, for shortcuts to // web pages.) final Intent intent = info.intent; final ComponentName name = intent.getComponent(); // PersonaLog.d("Personalauncher","name " + name.flattenToString()); //Badge switch (updateCounterFor) { case UPDATE_COUNTERS_FOR_DIALER: if (name.flattenToString().contains("DialerParentActivity")) { //BADGE - below lines from if loop below added since that if loop fails if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); //BADGE ends } break; case UPDATE_COUNTERS_FOR_MESSENGER: if (name.flattenToString().contains("SmsListdisplay")) { //BADGE - below lines from if loop below added since that if loop fails if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); //BADGE ends } break; } if ((info.itemType == PersonaLauncherSettings.Favorites.ITEM_TYPE_APPLICATION || info.itemType == PersonaLauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) && Intent.ACTION_MAIN.equals(intent.getAction()) && name != null && packageName.equals(name.getPackageName())) { if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); } } else { //PersonaLog.d("personalauncher","------ tag is not an instance of personaApplicationInfo-----"); //if(tag != null) // PersonaLog.d("personalauncher","------- tag not an instance of personaapplicationinfo ---- "+ tag.toString()); } }
From source file:com.zoffcc.applications.zanavi.Navit.java
@SuppressLint("NewApi") public boolean onOptionsItemSelected_wrapper(int id) { // Handle item selection switch (id) { case 1://w w w. j av a 2 s . c o m // zoom in Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 1); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // if we zoom, hide the bubble if (N_NavitGraphics.NavitAOverlay != null) { N_NavitGraphics.NavitAOverlay.hide_bubble(); } Log.e("Navit", "onOptionsItemSelected -> zoom in"); break; case 2: // zoom out msg = new Message(); b = new Bundle(); b.putInt("Callback", 2); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // if we zoom, hide the bubble if (N_NavitGraphics.NavitAOverlay != null) { N_NavitGraphics.NavitAOverlay.hide_bubble(); } Log.e("Navit", "onOptionsItemSelected -> zoom out"); break; case 3: // map download menu Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class); this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id); break; case 5: toggle_poi_pref(); set_poi_layers(); draw_map(); break; case 6: // ok startup address search activity (online google maps search) Navit.use_index_search = false; Intent search_intent = new Intent(this, NavitAddressSearchActivity.class); search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS search_intent.putExtra("address_string", Navit_last_address_search_string); //search_intent.putExtra("hn_string", Navit_last_address_hn_string); search_intent.putExtra("type", "online"); String pm_temp = "0"; if (Navit_last_address_partial_match) { pm_temp = "1"; } search_intent.putExtra("partial_match", pm_temp); this.startActivityForResult(search_intent, NavitAddressSearch_id_online); break; case 7: // ok startup address search activity (offline binfile search) Navit.use_index_search = Navit.allow_use_index_search(); Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class); search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS search_intent2.putExtra("address_string", Navit_last_address_search_string); search_intent2.putExtra("hn_string", Navit_last_address_hn_string); search_intent2.putExtra("type", "offline"); search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id); String pm_temp2 = "0"; if (Navit_last_address_partial_match) { pm_temp2 = "1"; } search_intent2.putExtra("partial_match", pm_temp2); this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline); break; case 8: // map delete menu Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class); this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id); break; case 9: // stop navigation (this menu should only appear when navigation is actually on!) Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putInt("Callback", 7); msg2.setData(b2); NavitGraphics.callback_handler.sendMessage(msg2); Log.e("Navit", "stop navigation"); break; case 10: // open settings menu Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class); startActivity(settingsActivity); break; case 11: //zoom_to_route zoom_to_route(); break; case 12: // --------- make app crash --------- // --------- make app crash --------- // --------- make app crash --------- // ** // DEBUG // ** // crash_app_java(1); // ** // DEBUG // ** // crash_app_C(); // --------- make app crash --------- // --------- make app crash --------- // --------- make app crash --------- // announcer off Navit_Announcer = false; msg = new Message(); b = new Bundle(); b.putInt("Callback", 34); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { invalidateOptionsMenu(); } catch (Exception e) { } break; case 13: // announcer on Navit_Announcer = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 35); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { invalidateOptionsMenu(); } catch (Exception e) { } break; case 14: // show recent destination list Intent i2 = new Intent(this, NavitRecentDestinationActivity.class); this.startActivityForResult(i2, Navit.NavitRecentDest_id); break; case 15: // show current target on googlemaps String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1); // Log.e("Navit", "got target 1: "+current_target_string); if (current_target_string.equals("x:x")) { Log.e("Navit", "no target set!"); } else { try { String tmp[] = current_target_string.split(":", 2); googlemaps_show(tmp[0], tmp[1], "ZANavi Target"); } catch (Exception e) { e.printStackTrace(); Log.e("Navit", "problem with target!"); } } break; case 16: // show online manual Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase()); // URL to ZANavi Manual (in english language) String url = "http://zanavi.cc/index.php/Manual"; if (FDBL) { url = "http://fd.zanavi.cc/manual"; } if (NavitTextTranslations.main_language.toLowerCase().equals("de")) { // show german manual url = "http://zanavi.cc/index.php/Manual/de"; if (FDBL) { url = "http://fd.zanavi.cc/manualde"; } } Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); break; case 17: // show age of maps (online) Intent i3 = new Intent(Intent.ACTION_VIEW); i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL)); startActivity(i3); break; case 18: Intent intent_latlon = new Intent(Intent.ACTION_MAIN); //intent_latlon.setAction("android.intent.action.POINTPICK"); intent_latlon.setPackage("com.cruthu.latlongcalc1"); intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain"); //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick"); try { startActivity(intent_latlon); } catch (Exception e88) { e88.printStackTrace(); // show install page try { // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1"; String urlx = "market://details?id=com.cruthu.latlongcalc1"; Intent ix = new Intent(Intent.ACTION_VIEW); ix.setData(Uri.parse(urlx)); startActivity(ix); } catch (Exception ex) { ex.printStackTrace(); } } break; case 19: // GeoCoordEnterDialog Intent it001 = new Intent(this, GeoCoordEnterDialog.class); this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id); break; case 20: // convert GPX file Intent intent77 = new Intent(getBaseContext(), FileDialog.class); File a = new File(p.PREF_last_selected_dir_gpxfiles); try { // convert the "/../" in the path to normal absolut dir intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath()); //can user select directories or not intent77.putExtra(FileDialog.CAN_SELECT_DIR, false); // disable the "new" button intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); //alternatively you can set file filter //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" }); startActivityForResult(intent77, Navit.NavitGPXConvChooser_id); } catch (IOException e1) { e1.printStackTrace(); } break; case 21: // add traffic block (like blocked road, or construction site) at current location of crosshair try { String traffic = ""; if (Navit.GFX_OVERSPILL) { traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill)), (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill))); } else { traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2)); } // System.out.println("traffic=" + traffic); File traffic_file_dir = new File(MAP_FILENAME_PATH); traffic_file_dir.mkdirs(); File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt"); FileOutputStream fOut = null; OutputStreamWriter osw = null; try { fOut = new FileOutputStream(traffic_file, true); osw = new OutputStreamWriter(fOut); osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header osw.write(traffic); // item coordinates osw.close(); fOut.close(); } catch (Exception ef) { ef.printStackTrace(); } // update route, if a route is set msg = new Message(); b = new Bundle(); b.putInt("Callback", 73); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); } break; case 22: // clear all traffic blocks try { File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt"); traffic_file.delete(); // update route, if a route is set msg = new Message(); b = new Bundle(); b.putInt("Callback", 73); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } break; case 23: // clear all GPX maps try { File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt"); gpx_file.delete(); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } break; case 24: // show feedback form Intent i4 = new Intent(this, NavitFeedbackFormActivity.class); this.startActivityForResult(i4, Navit.NavitSendFeedback_id); break; case 25: // share the current destination with your friends String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1); if (current_target_string2.equals("x:x")) { Log.e("Navit", "no target set!"); } else { try { String tmp[] = current_target_string2.split(":", 2); if (Navit.OSD_route_001.arriving_time_valid) { share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true); } else { share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true); } } catch (Exception e) { e.printStackTrace(); Log.e("Navit", "problem with target!"); } } break; case 26: // donate Log.e("Navit", "start donate app"); donate(); break; case 27: // donate Log.e("Navit", "donate bitcoins"); donate_bitcoins(); break; case 28: // replay GPS file Intent intent771 = new Intent(getBaseContext(), FileDialog.class); File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR); try { // convert the "/../" in the path to normal absolut dir intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath()); //can user select directories or not intent771.putExtra(FileDialog.CAN_SELECT_DIR, false); // disable the "new" button intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); //alternatively you can set file filter intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" }); startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id); } catch (IOException e1) { e1.printStackTrace(); } break; case 29: // About Screen Intent it002 = new Intent(this, ZANaviAboutPage.class); this.startActivityForResult(it002, Navit.ZANaviAbout_id); break; case 88: // dummy entry, just to make "breaks" in the menu break; case 601: // DEBUG: activate demo vehicle and set position to position to screen center Navit.DemoVehicle = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 101); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); final Thread demo_v_001 = new Thread() { @Override public void run() { try { Thread.sleep(1000); // wait 1 seconds before we start try { float lat = 0; float lon = 0; String lat_lon = ""; if (Navit.GFX_OVERSPILL) { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill)); } else { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2); } String tmp[] = lat_lon.split(":", 2); //System.out.println("tmp=" + lat_lon); lat = Float.parseFloat(tmp[0]); lon = Float.parseFloat(tmp[1]); //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); Location l = null; l = new Location("ZANavi Demo 001"); l.setLatitude(lat); l.setLongitude(lon); l.setBearing(0.0f); l.setSpeed(0); l.setAccuracy(4.0f); // accuracy 4 meters // NavitVehicle.update_compass_heading(0.0f); NavitVehicle.set_mock_location__fast(l); } catch (Exception e) { } Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 52); b.putString("s", "45"); // speed in km/h of Demo-Vehicle // b.putString("s", "20"); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } } }; demo_v_001.start(); msg = new Message(); b = new Bundle(); b.putInt("Callback", 51); if (Navit.GFX_OVERSPILL) { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill))); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill))); } else { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); } msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 602: // DEBUG: toggle textview with spoken and translated string (to help with translation) try { if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) { NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE); NavitGraphics.NavitMsgTv2_.setEnabled(false); NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE); NavitGraphics.NavitMsgTv2sc_.setEnabled(false); } else { NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE); NavitGraphics.NavitMsgTv2sc_.setEnabled(true); NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE); NavitGraphics.NavitMsgTv2_.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); } break; case 603: // DEBUG: show all possible navigation commands (also translated) NavitGraphics.generate_all_speech_commands(); break; case 604: // DEBUG: activate FAST driving demo vehicle and set position to screen center Navit.DemoVehicle = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 52); b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); msg = new Message(); b = new Bundle(); b.putInt("Callback", 51); if (Navit.GFX_OVERSPILL) { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill))); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill))); } else { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); } msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { float lat = 0; float lon = 0; lat = 0; lon = 0; String lat_lon = ""; if (Navit.GFX_OVERSPILL) { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill)); } else { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2); } String tmp[] = lat_lon.split(":", 2); //System.out.println("tmp=" + lat_lon); lat = Float.parseFloat(tmp[0]); lon = Float.parseFloat(tmp[1]); //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); Location l = null; l = new Location("ZANavi Demo 001"); l.setLatitude(lat); l.setLongitude(lon); l.setBearing(0.0f); l.setSpeed(0); l.setAccuracy(4.0f); // accuracy 4 meters // NavitVehicle.update_compass_heading(0.0f); NavitVehicle.set_mock_location__fast(l); } catch (Exception e) { } break; case 605: // DEBUG: toggle Routgraph on/off msg = new Message(); b = new Bundle(); b.putInt("Callback", 71); Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled; b.putString("s", "" + Navit.Routgraph_enabled); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 606: // DEBUG: spill contents of index file(s) msg = new Message(); b = new Bundle(); b.putInt("Callback", 83); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 607: export_map_points_to_sdcard(); break; case 608: import_map_points_from_sdcard(); break; case 609: // run yaml tests new Thread() { public void run() { try { ZANaviDebugReceiver.DR_run_all_yaml_tests(); } catch (Exception e) { } } }.start(); break; case 99: try { if (wl_navigating != null) { //if (wl_navigating.isHeld()) //{ wl_navigating.release(); Log.e("Navit", "WakeLock Nav: release 1"); //} } } catch (Exception e) { e.printStackTrace(); } // exit this.onPause(); this.onStop(); this.exit(); //msg = new Message(); //b = new Bundle(); //b.putInt("Callback", 5); //b.putString("cmd", "quit();"); //msg.setData(b); //N_NavitGraphics.callback_handler.sendMessage(msg); break; } return true; }