Example usage for android.content.res Resources getString

List of usage examples for android.content.res Resources getString

Introduction

In this page you can find the example usage for android.content.res Resources getString.

Prototype

@NonNull
public String getString(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:com.codetroopers.betterpickers.radialtimepicker.CircleView.java

public void initialize(Context context, boolean is24HourMode) {
    if (mIsInitialized) {
        Log.e(TAG, "CircleView may only be initialized once.");
        return;/*from  www .  j  a  v  a 2  s . co  m*/
    }

    Resources res = context.getResources();
    mIs24HourMode = is24HourMode;
    if (is24HourMode) {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier));
    }

    mIsInitialized = true;
}

From source file:com.outsystemscloud.andrevieira.secureDevice.java

private void checkDevice() {
    boolean _isDeviceRooted = isDeviceRooted();
    boolean _isPasscodeSet = doesDeviceHaveSecuritySetup(this.cordova.getActivity());

    if (_isDeviceRooted || !_isPasscodeSet) {
        // Remove View
        View v = this.view.getView();
        ViewGroup viewParent = (ViewGroup) v.getParent();
        viewParent.removeView(v);//from  ww w  .jav  a2  s.  c  om

        // Show message and quit
        Application app = cordova.getActivity().getApplication();
        String package_name = app.getPackageName();
        Resources resources = app.getResources();
        String message = resources.getString(resources.getIdentifier("message", "string", package_name));
        String label = resources.getString(resources.getIdentifier("label", "string", package_name));
        this.alert(message, label);
    }
}

From source file:com.gotraveling.insthub.BeeFramework.activity.CrashLogActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.crash_log_activity);
    logListView = (XListView) findViewById(R.id.log_list_view);
    titleTextView = (TextView) findViewById(R.id.navigationbar_title);

    Resources resource = (Resources) getBaseContext().getResources();
    String log_str = resource.getString(R.string.crash_log_analysis);
    titleTextView.setText(log_str);// w ww  . ja  va  2s  . co  m

    new Thread() {
        @Override
        public void run() {
            initLog();
        }
    }.start();

    logListView.setPullLoadEnable(false);
    logListView.setPullRefreshEnable(false);
    logListView.setRefreshTime();

    listAdapter = new CrashLogAdapter(this, crashMessageArrayList);
    logListView.setAdapter(listAdapter);

    logListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            int size = crashMessageArrayList.size();
            CrashMessage crashMessage = crashMessageArrayList.get(size - position);
            Intent it = new Intent(CrashLogActivity.this, CrashLogDetailActivity.class);
            it.putExtra("crash_time", crashMessage.crashTime);
            it.putExtra("crash_content", crashMessage.crashContent);
            startActivity(it);
        }
    });

}

From source file:com.achep.acdisplay.notifications.NotificationListenerJellyBeanMR2.java

@Override
public void onListenerBind(@NonNull MediaService service) {
    mInitialized = false;/*from  w  w  w.  ja v  a2 s .  c om*/

    // What is the idea of init notification?
    // Well the main goal is to access #getActiveNotifications()
    // what seems to be not possible without dirty and buggy
    // workarounds.
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            MediaService service = MediaService.sService;
            if (service == null)
                return;

            Resources res = service.getResources();
            NotificationCompat.Builder builder = new NotificationCompat.Builder(service)
                    .setContentTitle(res.getString(R.string.app_name))
                    .setContentText(res.getString(R.string.notification_init_text))
                    .setSmallIcon(R.drawable.stat_notify).setPriority(Notification.PRIORITY_MIN)
                    .setAutoCancel(true).setColor(App.ACCENT_COLOR);

            String name = Context.NOTIFICATION_SERVICE;
            NotificationManager nm = (NotificationManager) service.getSystemService(name);
            nm.notify(App.ID_NOTIFY_INIT, builder.build());
        }
    }, 2000);
}

From source file:com.appdevkit.push.PushService.java

@Override
public void onCreate() {
    super.onCreate();
    Log.i(TAG, "PushService onCreate()");

    // Initialize PubNub 3.3 object with appropriate subscriber key.
    Resources res = getResources();
    this.subscriberKey = res.getString(R.string.adk_subscriber_key);

    Log.i(TAG, this.subscriberKey);

    this.channelName = res.getString(R.string.adk_channel_name);

    pubnub = new Pubnub("", this.subscriberKey);

    subscriberThread = new Thread(runner);
    subscriberThread.start();/*from   w w  w. j a v a2  s.  c om*/
}

From source file:com.autburst.picture.FinishedUploadActivity.java

private void postToFacebook() {
    String videoUrl = createVideoUrl();
    if (videoUrl == null) {
        return;//from  www  .  ja  va  2  s  . c  o  m
    }
    Log.d(TAG, "videoUrl for FB: " + videoUrl);

    videoUrl = URLEncoder.encode(videoUrl);
    Intent intent = new Intent(this, FacebookActivity.class);

    Resources res = getResources();
    intent.putExtra("application_id", "126691144034061");
    intent.putExtra("message", String.format(res.getString(R.string.fb_message),
            new String(Base64.decodeBase64(albumName.getBytes()))));
    intent.putExtra("link", videoUrl);
    intent.putExtra("name", "ApicAday");
    intent.putExtra("caption", res.getString(R.string.fb_caption));
    intent.putExtra("description", "");
    intent.putExtra("picture", "http://server.autburst.com/ApicAday/facebook_image_finish.png");
    startActivity(intent);
}

From source file:com.gotraveling.insthub.BeeFramework.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (isExit == false) {
            isExit = true;/*from w  w  w  .jav  a 2  s  .c om*/
            Resources resource = (Resources) getBaseContext().getResources();
            String exi = resource.getString(R.string.exit);
            Toast.makeText(getApplicationContext(), exi, Toast.LENGTH_SHORT).show();
            handler.sendEmptyMessageDelayed(0, 3000);
            if (BeeQuery.environment() == BeeQuery.ENVIROMENT_DEVELOPMENT) {
                BeeFrameworkApp.getInstance().showBug(this);
            }

            return true;
        } else {
            finish();

            return false;
        }
    }
    return true;
}

From source file:com.vrem.wifianalyzer.wifi.timegraph.TimeGraphView.java

private GraphView makeGraphView(@NonNull MainActivity mainActivity, int graphMaximumY) {
    Resources resources = mainActivity.getResources();
    return new GraphViewBuilder(mainActivity, getNumX(), graphMaximumY).setLabelFormatter(new TimeAxisLabel())
            .setVerticalTitle(resources.getString(R.string.graph_axis_y))
            .setHorizontalTitle(resources.getString(R.string.graph_time_axis_x))
            .setHorizontalLabelsVisible(false).build();
}

From source file:com.chintans.venturebox.util.Utils.java

public static void showNotification(Context context, PackageInfo[] infosRom, PackageInfo[] infosGapps) {
    Resources resources = context.getResources();

    if (infosRom != null) {
        sPackageInfosRom = infosRom;//  ww  w.ja v a 2s. co m
    } else {
        infosRom = sPackageInfosRom;
    }
    if (infosGapps != null) {
        sPackageInfosGapps = infosGapps;
    } else {
        infosGapps = sPackageInfosGapps;
    }

    Intent intent = new Intent(context, MainActivity.class);
    NotificationInfo fileInfo = new NotificationInfo();
    fileInfo.mNotificationId = Updater.NOTIFICATION_ID;
    fileInfo.mPackageInfosRom = infosRom;
    fileInfo.mPackageInfosGapps = infosGapps;
    intent.putExtra(FILES_INFO, fileInfo);
    PendingIntent pIntent = PendingIntent.getActivity(context, Updater.NOTIFICATION_ID, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(resources.getString(R.string.new_system_update))
            .setSmallIcon(R.drawable.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.ic_launcher))
            .setContentIntent(pIntent);

    String contextText = "";
    if (infosRom.length + infosGapps.length == 1) {
        String filename = infosRom.length == 1 ? infosRom[0].getFilename() : infosGapps[0].getFilename();
        contextText = resources.getString(R.string.new_package_name, new Object[] { filename });
    } else {
        contextText = resources.getString(R.string.new_packages,
                new Object[] { infosRom.length + infosGapps.length });
    }
    builder.setContentText(contextText);

    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle(context.getResources().getString(R.string.new_system_update));
    if (infosRom.length + infosGapps.length > 1) {
        inboxStyle.addLine(contextText);
    }
    for (int i = 0; i < infosRom.length; i++) {
        inboxStyle.addLine(infosRom[i].getFilename());
    }
    for (int i = 0; i < infosGapps.length; i++) {
        inboxStyle.addLine(infosGapps[i].getFilename());
    }
    inboxStyle.setSummaryText(resources.getString(R.string.app_name));
    builder.setStyle(inboxStyle);

    Notification notif = builder.build();

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Service.NOTIFICATION_SERVICE);

    notif.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(Updater.NOTIFICATION_ID, notif);
}

From source file:net.kayateia.lifestream.UploadService.java

private boolean initStorage() {
    try {//from   w ww  . j  a v a 2s  . co  m
        if (!Media.IsMediaMounted()) {
            Log.i(LOG_TAG, "External storage not mounted; trying again later.");
            return false;
        }
        _storagePath = Media.InitStorage(this, CaptureService.UPLOAD_DIRECTORY_NAME, false);
        _tempThumbPath = Media.InitStorage(this, NOTIFICATION_THUMBNAIL_PATH, true);
    } catch (Exception e) {
        final Resources res = getResources();
        Notifications.NotifyError(this, NOTIFY_ID, false, res.getString(R.string.fail_ticker),
                res.getString(R.string.fail_title), e.getMessage());
        Log.e(LOG_TAG, "Couldn't init storage: " + e);
    }

    return _storagePath != null;
}