List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:com.kakao.KakaoLink.java
/** * ? ?? .//ww w . j a v a 2 s. com * @param linkMessage contents * @param context ? context */ public void sendMessage(final String linkMessage, final Context context) throws KakaoParameterException { final Intent intent = TalkProtocol.createKakakoTalkLinkIntent(context, linkMessage); if (intent == null) { //alert install dialog new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert) .setMessage(context.getString(string.com_kakao_alert_install_kakaotalk)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(KakaoTalkLinkProtocol.TALK_MARKET_URL_PREFIX + makeReferrer()))); } }).create().show(); } else { context.startActivity(intent); } }
From source file:com.nextgis.maplibui.mapui.LayerFactoryUI.java
@Override public void createNewLocalTMSLayer(final Context context, final LayerGroup groupLayer, final Uri uri) { String ext = "zip"; String layerName = FileUtil.getFileNameByUri(context, uri, context.getString(R.string.new_layer)); final int lastPeriodPos = layerName.lastIndexOf('.'); if (lastPeriodPos > 0) { ext = layerName.substring(lastPeriodPos).toLowerCase(); layerName = layerName.substring(0, lastPeriodPos); }/*from ww w .j a va 2s . c om*/ if (context instanceof NGActivity) { NGActivity fragmentActivity = (NGActivity) context; if (ext.equals(".ngrc")) { Intent intent = new Intent(context, LayerFillService.class); intent.setAction(LayerFillService.ACTION_ADD_TASK); intent.putExtra(LayerFillService.KEY_URI, uri); intent.putExtra(LayerFillService.KEY_INPUT_TYPE, LayerFillService.TMS_LAYER); intent.putExtra(LayerFillService.KEY_LAYER_GROUP_ID, groupLayer.getId()); LayerFillProgressDialogFragment.startFill(intent); return; } AtomicReference<Uri> temp = new AtomicReference<>(uri); if (MapUtil.isZippedGeoJSON(context, temp)) { createNewVectorLayer(context, groupLayer, temp.get()); return; } CreateLocalLayerDialog newFragment = new CreateLocalLayerDialog(); newFragment.setLayerGroup(groupLayer).setLayerType(LayerFillService.TMS_LAYER).setUri(uri) .setLayerName(layerName).setTitle(context.getString(R.string.create_tms_layer)) .setTheme(fragmentActivity.getThemeId()) .show(fragmentActivity.getSupportFragmentManager(), "create_tms_layer"); } }
From source file:com.nextgis.maplibui.mapui.LayerFactoryUI.java
private void startNGWResourceActivity(Context context, Connection connection, LayerGroup layerGroup) { Intent intent = new Intent(context, SelectNGWResourceActivity.class); Connections connections = new Connections(context.getString(R.string.ngw_accounts)); connections.add(connection);//from www . j a v a 2 s . c o m intent.putExtra(SelectNGWResourceActivity.KEY_TASK, SelectNGWResourceActivity.TYPE_ADD); intent.putExtra(SelectNGWResourceActivity.KEY_CONNECTIONS, connections); intent.putExtra(SelectNGWResourceActivity.KEY_RESOURCE_ID, connections.getChild(0).getId()); intent.putExtra(SelectNGWResourceActivity.KEY_GROUP_ID, layerGroup.getId()); context.startActivity(intent); }
From source file:org.herrlado.websms.connector.myphone.ConnectorMyphone.java
/** * {@inheritDoc}/*from w ww . j a v a 2 s . c o m*/ */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.myphone_name); final ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(// . context.getString(R.string.myphone_author)); c.setBalance(null); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector("myphone.ge", c.getName(), SubConnectorSpec.FEATURE_CUSTOMSENDER | SubConnectorSpec.FEATURE_SENDLATER); return c; }
From source file:com.codeskraps.lolo.misc.Utils.java
public static PendingIntent getOnTouchIntent(Context context) { PendingIntent pendingIntent = null;/* w w w .j a va 2 s . c o m*/ Intent intent = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int onClick = Integer.parseInt(prefs.getString(Constants.ONCLICK, "0")); switch (onClick) { case 0: intent = new Intent("com.codeskraps.lol.DO_NOTHING"); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 1: intent = new Intent(context, TweetsFeedActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 2: intent = new Intent(); intent.setAction(Constants.BROADCAST_RECEIVER); pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: intent = new Intent(context, PrefsActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: intent = new Intent(Intent.ACTION_VIEW); String url = prefs.getString(Constants.EURL, context.getString(R.string.prefsURL_default)); if (!url.startsWith("http://")) url = "http://" + url; intent.setData(Uri.parse(url)); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; } return pendingIntent; }
From source file:com.owncloud.android.lib.test_project.test.CopyFileTest.java
private void initAccessToServer(Context context) { Log.v(LOG_TAG, "Setting up client instance to access OC server..."); mServerUri = context.getString(R.string.server_base_url); mUser = context.getString(R.string.username); mPass = context.getString(R.string.password); mClient = new OwnCloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager()); mClient.setDefaultTimeouts(OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT, OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT); mClient.setFollowRedirects(true);/* w w w.ja v a 2s . co m*/ mClient.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(mUser, mPass)); Log.v(LOG_TAG, "Client instance set up."); }
From source file:org.herrlado.websms.connector.mycoolsms.Connector.java
/** * {@inheritDoc}//w w w . j a v a2 s . c o m */ @Override public ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(// . context.getString(R.string.connector_author)); c.setBalance(null); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector("my-cool-sms.com", c.getName(), SubConnectorSpec.FEATURE_CUSTOMSENDER); return c; }
From source file:ir.keloud.android.lib.test_project.test.MoveFileTest.java
private void initAccessToServer(Context context) { Log.v(LOG_TAG, "Setting up client instance to access OC server..."); mServerUri = context.getString(R.string.server_base_url); mUser = context.getString(R.string.username); mPass = context.getString(R.string.password); mClient = new KeloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager()); mClient.setDefaultTimeouts(KeloudClientFactory.DEFAULT_DATA_TIMEOUT, KeloudClientFactory.DEFAULT_CONNECTION_TIMEOUT); mClient.setFollowRedirects(true);/*from w w w .j a v a 2 s . c om*/ mClient.setCredentials(KeloudCredentialsFactory.newBasicCredentials(mUser, mPass)); Log.v(LOG_TAG, "Client instance set up."); }
From source file:com.wso2.mobile.mdm.utils.ServerUtilities.java
public static Map<String, String> sendWithTimeWait(String epPostFix, Map<String, String> params, String option, Context context) { Map<String, String> response = null; Map<String, String> responseFinal = null; long backoff = BACKOFF_MILLI_SECONDS + random.nextInt(1000); for (int i = 1; i <= MAX_ATTEMPTS; i++) { Log.d(TAG, "Attempt #" + i + " to register"); try {//from w ww . ja v a2 s . c o m //response = sendToServer(epPostFix, params, option, context); response = postData(context, epPostFix, params); if (response != null && !response.equals(null)) { responseFinal = response; } GCMRegistrar.setRegisteredOnServer(context, true); String message = context.getString(R.string.server_registered); Log.v("Check Reg Success", message.toString()); return responseFinal; } catch (Exception e) { Log.e(TAG, "Failed to register on attempt " + i, e); if (i == MAX_ATTEMPTS) { break; } return responseFinal; } } String message = context.getString(R.string.server_register_error, MAX_ATTEMPTS); return responseFinal; }
From source file:fr.shywim.antoinedaniel.utils.Utils.java
/** * Increment an achievement./*from w w w . j a va 2s. c o m*/ * * @param context Any context. * @param resid Achievement's id. */ public void incrementAchievement(Context context, int resid) { String id = context.getString(resid); if (apiClient != null && apiClient.isConnected()) { Games.Achievements.increment(apiClient, id, 1); } }