List of usage examples for android.content Context POWER_SERVICE
String POWER_SERVICE
To view the source code for android.content Context POWER_SERVICE.
Click Source Link
From source file:dong.lan.tuyi.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from ww w . j a v a2s .c om*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText(AES.decode(toChatUsername)); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.dcy.psychology.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from w ww. j av a 2s .c om*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ? toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.name)).setText(toChatUsername); // Map<String,RobotUser> robotMap=((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotList(); // if(robotMap!=null&&robotMap.containsKey(toChatUsername)){ // isRobot = true; // String nick = robotMap.get(toChatUsername).getNick(); // if(!TextUtils.isEmpty(nick)){ // ((TextView) findViewById(R.id.name)).setText(nick); // }else{ // ((TextView) findViewById(R.id.name)).setText(toChatUsername); // } // }else{ // ((TextView) findViewById(R.id.name)).setText(toChatUsername); // } } else { // findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.newsrob.EntryManager.java
private void switchStorageProvider() { Log.d(TAG, "Switch Storage Provider"); if (isModelCurrentlyUpdated()) return;/* ww w . j a v a 2s . c om*/ final String newPrefValue = getSharedPreferences().getString(SETTINGS_STORAGE_PROVIDER_KEY, null); final String oldStorageProviderClass = fileContextAdapter.getClass().getName(); final String newStorageProviderClass = STORAGE_PROVIDER_SD_CARD.equals(newPrefValue) ? SdCardStorageAdapter.class.getName() : PhoneMemoryStorageAdapter.class.getName(); if (!oldStorageProviderClass.equals(newStorageProviderClass)) { runningThread = new Thread(new Runnable() { public void run() { final PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); Log.i(TAG, "Wake lock acquired at " + new Date().toString() + "."); wl.acquire(); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); final Timing t = new Timing("Storage Provider Switch", ctx); ModelUpdateResult result = null; if (isModelCurrentlyUpdated()) return; try { lockModel("EM.switchStorageProvider.run"); } catch (final IllegalStateException ise) { return; } try { Log.i(TAG, "Switching storage providers started at " + new Date().toString() + "."); fireModelUpdateStarted("Switching storage providers", false, true); Log.d(TAG, "Change of storage provider detected."); final List<Job> jobList = new LinkedList<Job>(); final Job clearOldStorageProvider = new Job("Clearing Old Storage Provider", EntryManager.this) { @Override public void run() { Log.d(TAG, "Clearing the old storage provider."); doClearCache(); if (fileContextAdapter.canWrite()) WebPageDownloadDirector.removeAllAssets(fileContextAdapter); } }; jobList.add(clearOldStorageProvider); final Job switchStorageProviders = new Job("Switching Storage Providers", EntryManager.this) { @Override public void run() throws Exception { Log.d(TAG, "Establishing new storage provider: " + newStorageProviderClass); fileContextAdapter = newStorageProviderClass.equals( SdCardStorageAdapter.class.getName()) ? new SdCardStorageAdapter(ctx) : new PhoneMemoryStorageAdapter(ctx); Log.d(TAG, "New storage provider established."); } }; jobList.add(switchStorageProviders); final Job clearNewStorageProvider = new Job("Clearing New Storage Provider", EntryManager.this) { @Override public void run() { Log.d(TAG, "Clearing the new storage provider."); doClearCache(); if (fileContextAdapter.canWrite()) WebPageDownloadDirector.removeAllAssets(fileContextAdapter); } }; jobList.add(clearNewStorageProvider); runJobs(jobList); result = new SwitchStorageProviderResult(); } catch (final Throwable throwable) { result = new SwitchStorageProviderFailed(throwable); Log.d(TAG, "Problem during switching storage providers.", throwable); t.stop(); } finally { unlockModel("EM.switchStorageProvider.run"); clearCancelState(); fireModelUpdateFinished(result); fireStatusUpdated(); Log.i(TAG, "Switching storage providers finished at " + new Date().toString() + "."); wl.release(); t.stop(); } } }, "Storage Provider Switch Worker"); runningThread.start(); } }
From source file:jackpal.androidterm.Term.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Log.v(TermDebug.LOG_TAG, "onCreate"); mPrivateAlias = new ComponentName(this, RemoteInterface.PRIVACT_ACTIVITY_ALIAS); if (icicle == null) onNewIntent(getIntent());// ww w . j ava2 s. c o m final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mSettings = new TermSettings(getResources(), mPrefs); mPrefs.registerOnSharedPreferenceChangeListener(this); boolean vimflavor = this.getPackageName().matches(".*vim.androidterm.*"); if (!vimflavor && mSettings.doPathExtensions()) { mPathReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String path = makePathFromBundle(getResultExtras(false)); if (intent.getAction().equals(ACTION_PATH_PREPEND_BROADCAST)) { mSettings.setPrependPath(path); } else { mSettings.setAppendPath(path); } mPendingPathBroadcasts--; if (mPendingPathBroadcasts <= 0 && mTermService != null) { populateViewFlipper(); populateWindowList(); } } }; Intent broadcast = new Intent(ACTION_PATH_BROADCAST); if (AndroidCompat.SDK >= 12) { broadcast.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES); } mPendingPathBroadcasts++; sendOrderedBroadcast(broadcast, PERMISSION_PATH_BROADCAST, mPathReceiver, null, RESULT_OK, null, null); if (mSettings.allowPathPrepend()) { broadcast = new Intent(broadcast); broadcast.setAction(ACTION_PATH_PREPEND_BROADCAST); mPendingPathBroadcasts++; sendOrderedBroadcast(broadcast, PERMISSION_PATH_PREPEND_BROADCAST, mPathReceiver, null, RESULT_OK, null, null); } } TSIntent = new Intent(this, TermService.class); startService(TSIntent); if (AndroidCompat.SDK >= 11) { int theme = mSettings.getColorTheme(); int actionBarMode = mSettings.actionBarMode(); mActionBarMode = actionBarMode; switch (actionBarMode) { case TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE: if (theme == 0) { setTheme(R.style.Theme_Holo); } else { setTheme(R.style.Theme_Holo_Light); } break; case TermSettings.ACTION_BAR_MODE_HIDES + 1: case TermSettings.ACTION_BAR_MODE_HIDES: if (theme == 0) { setTheme(R.style.Theme_Holo_ActionBarOverlay); } else { setTheme(R.style.Theme_Holo_Light_ActionBarOverlay); } break; } } else { mActionBarMode = TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE; } setContentView(R.layout.term_activity); mViewFlipper = (TermViewFlipper) findViewById(VIEW_FLIPPER); setFunctionKeyListener(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TermDebug.LOG_TAG); WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); int wifiLockMode = WifiManager.WIFI_MODE_FULL; if (AndroidCompat.SDK >= 12) { wifiLockMode = WIFI_MODE_FULL_HIGH_PERF; } mWifiLock = wm.createWifiLock(wifiLockMode, TermDebug.LOG_TAG); ActionBarCompat actionBar = ActivityCompat.getActionBar(this); if (actionBar != null) { mActionBar = actionBar; actionBar.setNavigationMode(ActionBarCompat.NAVIGATION_MODE_LIST); actionBar.setDisplayOptions(0, ActionBarCompat.DISPLAY_SHOW_TITLE); if (mActionBarMode >= TermSettings.ACTION_BAR_MODE_HIDES) { actionBar.hide(); } } mHaveFullHwKeyboard = checkHaveFullHwKeyboard(getResources().getConfiguration()); setSoftInputMode(mHaveFullHwKeyboard); if (mFunctionBar == -1) mFunctionBar = mSettings.showFunctionBar() ? 1 : 0; if (mFunctionBar == 1) setFunctionBar(mFunctionBar); updatePrefs(); permissionCheckExternalStorage(); mAlreadyStarted = true; }
From source file:com.easemob.qixin.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from w ww.j a v a 2s .c o m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); nick = getIntent().getStringExtra("nick"); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); if (nick == null) { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } else { ((TextView) findViewById(R.id.name)).setText(nick); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.aibasis.parent.ui.chat.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/* w w w .j a va 2s .c om*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true; String nick = robotMap.get(toChatUsername).getNick(); if (!TextUtils.isEmpty(nick)) { ((TextView) findViewById(R.id.name)).setText(nick); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } } else { UserUtils.setUserNick(toChatUsername, (TextView) findViewById(R.id.name)); } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.xpple.jahoqy.ui.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from ww w .j av a 2 s.com chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); final TextView nameTextview = (TextView) findViewById(R.id.name); BmobQuery<User> query = new BmobQuery<>(); query.addWhereEqualTo("mobilePhoneNumber", toChatUsername); query.findObjects(mContext, new FindListener<User>() { @Override public void onSuccess(List<User> list) { if (list != null && list.size() > 0) { nameTextview.setText(list.get(0).getUsername()); } } @Override public void onError(int i, String s) { } }); } else { // ? findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); onGroupViewCreation(); } if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } } }
From source file:com.example.testemdemo.ChatActivity.java
private void setUpView() { iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???/*from w w w . j a v a2 s. com*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); toChatUsername = "202"; // Map<String,RobotUser> robotMap=((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotList(); // if(robotMap!=null&&robotMap.containsKey(toChatUsername)){ // isRobot = true; // String nick = robotMap.get(toChatUsername).getNick(); // if(!TextUtils.isEmpty(nick)){ // ((TextView) findViewById(R.id.name)).setText(nick); // }else{ // ((TextView) findViewById(R.id.name)).setText(toChatUsername); // } // }else{ ((TextView) findViewById(R.id.name)).setText(toChatUsername); // } } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); if (chatType == CHATTYPE_GROUP) { onGroupViewCreation(); } else { onChatRoomViewCreation(); } } // for chatroom type, we only init conversation and create view adapter on success // if(chatType != CHATTYPE_CHATROOM){ // onConversationInit(); // // onListViewCreation(); // // // show forward message if the message is not null // String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); // if (forward_msg_id != null) { // // ????? // forwardMessage(forward_msg_id); // } // } }
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
private void updateBlankingBehavior() { boolean disableblanking = mSharedPreferences.getBoolean(Constants.DISABLEBLANKING, false); boolean disabledimming = mSharedPreferences.getBoolean(Constants.DISABLEDIMMING, false); if (disableblanking) { if (mWakeLock == null) { PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); if (disabledimming) { mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, WAKELOCK_TAG); } else { mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, WAKELOCK_TAG); }/*from w w w .j a v a 2 s . c o m*/ } if (mLoggerServiceManager.getLoggingState() == ExternalConstants.STATE_LOGGING && !mWakeLock.isHeld()) { mWakeLock.acquire(); Log.w(this, "Acquired lock to keep screen on!"); } } }
From source file:org.navitproject.navit.Navit.java
/** Called when the activity is first created. */ @Override/*from ww w . j ava 2 s.c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) this.requestWindowFeature(Window.FEATURE_NO_TITLE); else this.getActionBar().hide(); dialogs = new NavitDialogs(this); NavitResources = getResources(); // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.) Navit.startup_intent = this.getIntent(); // hack! Remember time stamps, and only allow 4 secs. later in onResume to set target! Navit.startup_intent_timestamp = System.currentTimeMillis(); Log.e("Navit", "**1**A " + startup_intent.getAction()); Log.e("Navit", "**1**D " + startup_intent.getDataString()); // init translated text NavitTextTranslations.init(); // NOTIFICATION // Setup the status bar notification // This notification is removed in the exit() function NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager Notification NavitNotification = new Notification(R.drawable.ic_notify, getString(R.string.notification_ticker), System.currentTimeMillis()); // Create a new notification, with the text string to show when the notification first appears PendingIntent appIntent = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0); // FIXME : needs a fix for sdk 23 // NavitNotification.setLatestEventInfo(getApplicationContext(), "Navit", getString(R.string.notification_event_default), appIntent); // Set the text in the notification // NavitNotification.flags|=Notification.FLAG_ONGOING_EVENT; // Ensure that the notification appears in Ongoing // nm.notify(R.string.app_name, NavitNotification); // Set the notification // Status and navigation bar sizes // These are platform defaults and do not change with rotation, but we have to figure out which ones apply // (is the navigation bar visible? on the side or at the bottom?) Resources resources = getResources(); int shid = resources.getIdentifier("status_bar_height", "dimen", "android"); int adhid = resources.getIdentifier("action_bar_default_height", "dimen", "android"); int nhid = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int nhlid = resources.getIdentifier("navigation_bar_height_landscape", "dimen", "android"); int nwid = resources.getIdentifier("navigation_bar_width", "dimen", "android"); status_bar_height = (shid > 0) ? resources.getDimensionPixelSize(shid) : 0; action_bar_default_height = (adhid > 0) ? resources.getDimensionPixelSize(adhid) : 0; navigation_bar_height = (nhid > 0) ? resources.getDimensionPixelSize(nhid) : 0; navigation_bar_height_landscape = (nhlid > 0) ? resources.getDimensionPixelSize(nhlid) : 0; navigation_bar_width = (nwid > 0) ? resources.getDimensionPixelSize(nwid) : 0; Log.d(TAG, String.format( "status_bar_height=%d, action_bar_default_height=%d, navigation_bar_height=%d, navigation_bar_height_landscape=%d, navigation_bar_width=%d", status_bar_height, action_bar_default_height, navigation_bar_height, navigation_bar_height_landscape, navigation_bar_width)); if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { Log.d(TAG, "ask for permission(s)"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION }, MY_PERMISSIONS_REQUEST_ALL); } // get the local language ------------- Locale locale = java.util.Locale.getDefault(); String lang = locale.getLanguage(); String langu = lang; String langc = lang; Log.e("Navit", "lang=" + lang); int pos = langu.indexOf('_'); if (pos != -1) { langc = langu.substring(0, pos); NavitLanguage = langc + langu.substring(pos).toUpperCase(locale); Log.e("Navit", "substring lang " + NavitLanguage.substring(pos).toUpperCase(locale)); // set lang. for translation NavitTextTranslations.main_language = langc; NavitTextTranslations.sub_language = NavitLanguage.substring(pos).toUpperCase(locale); } else { String country = locale.getCountry(); Log.e("Navit", "Country1 " + country); Log.e("Navit", "Country2 " + country.toUpperCase(locale)); NavitLanguage = langc + "_" + country.toUpperCase(locale); // set lang. for translation NavitTextTranslations.main_language = langc; NavitTextTranslations.sub_language = country.toUpperCase(locale); } Log.e("Navit", "Language " + lang); SharedPreferences prefs = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE); map_filename_path = prefs.getString("filenamePath", Environment.getExternalStorageDirectory().getPath() + "/navit/"); // make sure the new path for the navitmap.bin file(s) exist!! File navit_maps_dir = new File(map_filename_path); navit_maps_dir.mkdirs(); // make sure the share dir exists File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR); navit_data_share_dir.mkdirs(); Display display_ = getWindowManager().getDefaultDisplay(); int width_ = display_.getWidth(); int height_ = display_.getHeight(); metrics = new DisplayMetrics(); display_.getMetrics(Navit.metrics); int densityDpi = (int) ((Navit.metrics.density * 160) - .5f); Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_); Log.e("Navit", "Navit -> dpi=" + densityDpi); Log.e("Navit", "Navit -> density=" + Navit.metrics.density); Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity); ActivityResults = new NavitActivityResult[16]; setVolumeControlStream(AudioManager.STREAM_MUSIC); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen"); if (!extractRes(langc, NAVIT_DATA_DIR + "/locale/" + langc + "/LC_MESSAGES/navit.mo")) { Log.e("Navit", "Failed to extract language resource " + langc); } if (densityDpi <= 120) { my_display_density = "ldpi"; } else if (densityDpi <= 160) { my_display_density = "mdpi"; } else if (densityDpi < 240) { my_display_density = "hdpi"; } else if (densityDpi < 320) { my_display_density = "xhdpi"; } else if (densityDpi < 480) { my_display_density = "xxhdpi"; } else if (densityDpi < 640) { my_display_density = "xxxhdpi"; } else { Log.e("Navit", "found device of very high density (" + densityDpi + ")"); Log.e("Navit", "using xxxhdpi values"); my_display_density = "xxxhdpi"; } if (!extractRes("navit" + my_display_density, NAVIT_DATA_DIR + "/share/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml for " + my_display_density); } // --> dont use android.os.Build.VERSION.SDK_INT, needs API >= 4 Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK)); NavitMain(this, NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density, NAVIT_DATA_DIR + "/bin/navit", map_filename_path); showInfos(); Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); }