Example usage for android.content Context MODE_MULTI_PROCESS

List of usage examples for android.content Context MODE_MULTI_PROCESS

Introduction

In this page you can find the example usage for android.content Context MODE_MULTI_PROCESS.

Prototype

int MODE_MULTI_PROCESS

To view the source code for android.content Context MODE_MULTI_PROCESS.

Click Source Link

Document

SharedPreference loading flag: when set, the file on disk will be checked for modification even if the shared preferences instance is already loaded in this process.

Usage

From source file:Main.java

private static SharedPreferences getMultiDexPreferences(Context context) {
    return context.getSharedPreferences(PREFS_FILE,
            Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? Context.MODE_PRIVATE
                    : Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
}

From source file:org.andicar.service.UpdateCheckService.java

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    if (getSharedPreferences(StaticValues.GLOBAL_PREFERENCE_NAME, Context.MODE_MULTI_PROCESS)
            .getBoolean("SendCrashReport", true))
        Thread.setDefaultUncaughtExceptionHandler(
                new AndiCarExceptionHandler(Thread.getDefaultUncaughtExceptionHandler(), this));

    try {/*from w w  w  .j  av  a2s . c o  m*/
        Bundle extras = intent.getExtras();
        if (extras == null || extras.getBoolean("setJustNextRun") || !extras.getBoolean("AutoUpdateCheck")) {
            setNextRun();
            stopSelf();
        }

        URL updateURL = new URL(StaticValues.VERSION_FILE_URL);
        URLConnection conn = updateURL.openConnection();
        if (conn == null)
            return;
        InputStream is = conn.getInputStream();
        if (is == null)
            return;
        BufferedInputStream bis = new BufferedInputStream(is);
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }

        /* Convert the Bytes read to a String. */
        String s = new String(baf.toByteArray());
        /* Get current Version Number */
        int curVersion = getPackageManager().getPackageInfo("org.andicar.activity", 0).versionCode;
        int newVersion = Integer.valueOf(s);

        /* Is a higher version than the current already out? */
        if (newVersion > curVersion) {
            //get the whats new message
            updateURL = new URL(StaticValues.WHATS_NEW_FILE_URL);
            conn = updateURL.openConnection();
            if (conn == null)
                return;
            is = conn.getInputStream();
            if (is == null)
                return;
            bis = new BufferedInputStream(is);
            baf = new ByteArrayBuffer(50);
            current = 0;
            while ((current = bis.read()) != -1) {
                baf.append((byte) current);
            }

            /* Convert the Bytes read to a String. */
            s = new String(baf.toByteArray());

            mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            notification = null;
            Intent i = new Intent(this, WhatsNewDialog.class);
            i.putExtra("UpdateMsg", s);
            PendingIntent contentIntent = PendingIntent.getActivity(UpdateCheckService.this, 0, i, 0);

            CharSequence title = getText(R.string.Notif_UpdateTitle);
            String message = getString(R.string.Notif_UpdateMsg);
            notification = new Notification(R.drawable.icon_sys_info, message, System.currentTimeMillis());
            notification.flags |= Notification.DEFAULT_LIGHTS;
            notification.flags |= Notification.DEFAULT_SOUND;
            notification.flags |= Notification.FLAG_AUTO_CANCEL;
            notification.setLatestEventInfo(UpdateCheckService.this, title, message, contentIntent);
            mNM.notify(StaticValues.NOTIF_UPDATECHECK_ID, notification);
            setNextRun();
        }
        stopSelf();
    } catch (Exception e) {
        Log.i("UpdateService", "Service failed.");
        e.printStackTrace();
    }
}

From source file:de.tu_berlin.snet.commstat.EmailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    prefs = getActivity().getSharedPreferences("default", Context.MODE_MULTI_PROCESS);

    loadAccounts();//  www.  j  a v  a2 s.  c o m
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, list);
    setListAdapter(adapter);

    initSelection();
}

From source file:com.darshancomputing.BatteryIndicator.BatteryInfoActivity.java

public void loadSettingsFiles() {
    settings = context.getSharedPreferences(SettingsActivity.SETTINGS_FILE, Context.MODE_MULTI_PROCESS);
    sp_store = context.getSharedPreferences(SettingsActivity.SP_STORE_FILE, Context.MODE_MULTI_PROCESS);
}

From source file:org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedDataReader.java

public SpeedDataReader(Context context) {
    ctx = context;//from  w  ww.  j a  v a 2s  .  com
    SharedPreferences sharedPreferences = ctx.getSharedPreferences(SupportedSensors.SELECTED_SENSORS,
            Context.MODE_MULTI_PROCESS);
    Set<String> selectedSet = sharedPreferences.getStringSet(SupportedSensors.SELECTED_SENSORS_BY_USER, null);
    mSensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
    selectedSensorList(selectedSet);
    for (Sensor sensor : sensorList) {
        mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
    }

    LocalBroadcastManager.getInstance(ctx).registerReceiver(mMessageReceiver, new IntentFilter("speedUpdate"));

}

From source file:se.frikod.payday.DailyBudgetFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//w  w w .  j  a v  a2s  .c  o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    V = inflater.inflate(R.layout.daily_budget_fragment, container, false);

    activity = (PaydayActivity) this.getActivity();
    Context ctx = activity.getApplicationContext();

    FontUtils.setRobotoFont(ctx, activity.getWindow().getDecorView());
    FontUtils.setRobotoFont(ctx, activity.getWindow().getDecorView());
    prefs = activity.getPreferences(Context.MODE_MULTI_PROCESS);

    TextView addBudgetItem = (TextView) V.findViewById(R.id.addBudgetItemButton);
    addBudgetItem.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            addBudgetItem(v);
        }
    });

    budget = new Budget(activity.bank, ctx, new Holidays(ctx));
    updateBudget();
    updateBudgetItems();

    return V;
}

From source file:com.sentaroh.android.SMBSync2.CommonUtilities.java

@SuppressWarnings("deprecation")
@SuppressLint("InlinedApi")
final static public SharedPreferences getPrefMgr(Context c) {
    return c.getSharedPreferences(DEFAULT_PREFS_FILENAME, Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
}

From source file:com.happysanta.vkspy.Fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getActivity();//from   ww  w.j a v a 2s  . c om

    if (savedInstanceState != null && UberFunktion.loading) {
        ProgressDialog dialog = new ProgressDialog(context);
        dialog.setMessage(context.getString(R.string.durov_function_activating_message));
        UberFunktion.putNewDialogWindow(dialog);
        dialog.show();
    }

    View rootView = inflater.inflate(R.layout.fragment_main, null);

    View happySanta = inflater.inflate(R.layout.main_santa, null);

    TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText);
    happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description)));
    TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink);
    happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>"));
    happySantaLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta"));
            startActivity(browserIntent);
        }
    });
    happySanta.setOnClickListener(new View.OnClickListener() {
        int i = 1;

        @Override
        public void onClick(View v) {
            if (i < 10)
                i++;
            else {
                i = 0;
                File F = Logs.getFile();
                Uri U = Uri.fromFile(F);
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("text/plain");
                i.putExtra(Intent.EXTRA_STREAM, U);
                startActivity(Intent.createChooser(i, "What should we do with logs?"));
            }
        }
    });

    SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll",
            Context.MODE_MULTI_PROCESS);
    boolean longpollStatus = longpollPreferences.getBoolean("status", true);

    /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline);
    BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile);
    tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
    //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT);
            
    santaGroundView.setBackgroundDrawable(tiledBitmapDrawable);
            
    BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource(
        getResources(), R.drawable.underline2));
    bitmap.setTileModeX(Shader.TileMode.REPEAT);
    */
    LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line);
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth(); // deprecated

    for (int i = 0; width % (341 * i + 1) < width; i++) {
        layout.addView(new ImageView(context) {
            {
                setImageResource(R.drawable.underline2);
                setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4)));
                setScaleType(ScaleType.CENTER_CROP);
            }
        });
    }

    ListView preferencesView = (ListView) rootView.findViewById(R.id.preference);
    preferencesView.addHeaderView(happySanta, null, false);
    ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>();
    /*
    preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) {
    @Override
    public void onClick() {
            
        if(UberFunktion.loading) {
            ProgressDialog dialog = new ProgressDialog(context);
            dialog.setMessage(context.getString(R.string.durov_function_activating_message));
            UberFunktion.putNewDialogWindow(dialog);
            dialog.show();
            return;
        }
            
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        final AlertDialog selector;
        View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null);
        SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS);
        boolean updateOnly = durovPreferences.getBoolean("loaded", false);
        if(updateOnly)
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated);
            
            
        if(Memory.users.getById(1)!=null && !updateOnly) {
            builder.setTitle(R.string.durov_joke_title);
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message);
            ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE);
            
            builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
            BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1");
        }else{
            builder.setTitle(R.string.durov_start_title);
            
            ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo));
            builder.
                    setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
            
                            BugSenseHandler.sendEvent("  ");
                            ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(),
                                    context.getString(R.string.durov_function_activating_title),
                                    context.getString(R.string.durov_function_activating_message),
                                    true,
                                    false);
                            UberFunktion.initialize(uberfunctionDialog);
            
                        }
                    });
            builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    try {
                        Intent browserIntent = new Intent(
                                Intent.ACTION_VIEW,
                                Uri.parse("https://vk.com/id1")
                        );
                        startActivity(browserIntent);
            
                    }catch(Exception exp){
                        AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity());
                        if (exp instanceof ActivityNotFoundException) {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.no_browser);
            
                        } else {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.unknown_error);
                        }
                        errorShower.show();
                    }
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
        }
            
        builder.setView(durov);
        selector = builder.create();
        selector.show();
    }
    });
    */

    preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) {

        @Override
        public void onToggle(Boolean isChecked) {
            longpollToggle(isChecked);
        }
    });

    preferences.add(new PreferenceItem(getAdvancedSettings()) {
        @Override
        public void onClick() {
            startActivity(new Intent(context, SettingsActivity.class));
        }
    });

    preferences.add(new PreferenceItem(getAbout()) {
        @Override
        public void onClick() {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            final AlertDialog aboutDialog;
            builder.setTitle(R.string.app_about).setCancelable(true)
                    .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });

            View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null);

            TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description);
            aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description)));
            aboutDescription.setMovementMethod(LinkMovementMethod.getInstance());

            aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent browserIntent = new Intent(context, InfoActivity.class);
                    startActivity(browserIntent);
                }
            });

            builder.setView(aboutView);
            aboutDialog = builder.create();
            aboutDialog.setCanceledOnTouchOutside(true);
            aboutDialog.show();
        }
    });
    preferencesView.setAdapter(new PreferenceAdapter(context, preferences));

    return rootView;

}

From source file:com.dycody.android.idealnote.SettingsFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    this.activity = activity;
    prefs = activity.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS);
    setTitle();//from  ww  w. j av a2 s.co  m
}

From source file:org.zywx.wbpalmstar.engine.EBrowserWidget.java

public EBrowserWidget(Context context, WWidgetData inWidget, EWgtResultInfo inResult) {
    super(context);
    mWidgetData = inWidget;//from ww  w  .  jav a2s . c o  m
    mResultInfo = inResult;
    mContext = context;
    mEWindowStack = new EWindowStack();
    setAnimationCacheEnabled(false);
    setAlwaysDrawnWithCacheEnabled(false);
    EUtil.viewBaseSetting(this);
    mPres = mContext.getSharedPreferences("saveData", Context.MODE_MULTI_PROCESS);
    mPushNotifyWindName = mPres.getString(BConstant.F_PUSH_WIN_NAME, "");
    mPushNotifyFunctionName = mPres.getString(BConstant.F_PUSH_NOTI_FUN_NAME, "");
}