Example usage for android.content Context VIBRATOR_SERVICE

List of usage examples for android.content Context VIBRATOR_SERVICE

Introduction

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

Prototype

String VIBRATOR_SERVICE

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

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.Vibrator for interacting with the vibration hardware.

Usage

From source file:de.hshannover.f4.trust.ironcontrol.logic.ResultNotificationManager.java

private void vibrator() {

    Vibrator mVibratorService = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    mVibratorService.vibrate(new long[] { 0, 250, 500, 500 }, -1);

}

From source file:nth.com.ares.utils.Utils.java

public static void vibrate(int length, Context context) {
    Vibrator v1 = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    // Vibrate for [length] milliseconds
    v1.vibrate(length);//ww  w .  jav a 2  s  . c o  m

    // Output yes if can vibrate, no otherwise
    //        if (v1.hasVibrator()) {
    //            Log.v("Can Vibrate", "YES");
    //        } else {
    //            Log.v("Can Vibrate", "NO");
    //        }
}

From source file:de.schildbach.wallet.ui.scan.ScanActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    viewModel = ViewModelProviders.of(this).get(ScanViewModel.class);
    viewModel.showPermissionWarnDialog.observe(this, new Observer<Void>() {
        @Override//from   w  w w  .  jav  a  2s .com
        public void onChanged(final Void v) {
            WarnDialogFragment.show(getSupportFragmentManager(), R.string.scan_camera_permission_dialog_title,
                    getString(R.string.scan_camera_permission_dialog_message));
        }
    });
    viewModel.showProblemWarnDialog.observe(this, new Observer<Void>() {
        @Override
        public void onChanged(final Void v) {
            WarnDialogFragment.show(getSupportFragmentManager(), R.string.scan_camera_problem_dialog_title,
                    getString(R.string.scan_camera_problem_dialog_message));
        }
    });

    // Stick to the orientation the activity was started with. We cannot declare this in the
    // AndroidManifest.xml, because it's not allowed in combination with the windowIsTranslucent=true
    // theme attribute.
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
    // Draw under navigation and status bars.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

    setContentView(R.layout.scan_activity);
    contentView = findViewById(android.R.id.content);
    scannerView = (ScannerView) findViewById(R.id.scan_activity_mask);
    previewView = (TextureView) findViewById(R.id.scan_activity_preview);
    previewView.setSurfaceTextureListener(this);

    cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND);
    cameraThread.start();
    cameraHandler = new Handler(cameraThread.getLooper());

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 0);

    if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final Intent intent = getIntent();
        final int x = intent.getIntExtra(INTENT_EXTRA_SCENE_TRANSITION_X, -1);
        final int y = intent.getIntExtra(INTENT_EXTRA_SCENE_TRANSITION_Y, -1);
        if (x != -1 || y != -1) {
            // Using alpha rather than visibility because 'invisible' will cause the surface view to never
            // start up, so the animation will never start.
            contentView.setAlpha(0);
            getWindow().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            OnFirstPreDraw.listen(contentView, new OnFirstPreDraw.Callback() {
                @Override
                public boolean onFirstPreDraw() {
                    float finalRadius = (float) (Math.max(contentView.getWidth(), contentView.getHeight()));
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    sceneTransition = ViewAnimationUtils.createCircularReveal(contentView, x, y, 0,
                            finalRadius);
                    sceneTransition.setDuration(duration);
                    sceneTransition.setInterpolator(new AccelerateInterpolator());
                    // TODO Here, the transition should start in a paused state, showing the first frame
                    // of the animation. Sadly, RevealAnimator doesn't seem to support this, unlike
                    // (subclasses of) ValueAnimator.
                    return false;
                }
            });
        }
    }
}

From source file:com.imagine.BaseActivity.java

Vibrator systemVibrator() {
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    boolean hasVibrator = vibrator != null ? true : false;
    if (hasVibrator && android.os.Build.VERSION.SDK_INT >= 11) {
        // check if a vibrator is really present
        try {/*from w w  w  . j  a v a2s  .c o  m*/
            Method hasVibratorFunc = Vibrator.class.getMethod("hasVibrator");
            try {
                hasVibrator = (Boolean) hasVibratorFunc.invoke(vibrator);
            } catch (IllegalAccessException ie) {
                //Log.i(logTag, "IllegalAccessException calling hasVibratorFunc");
            } catch (InvocationTargetException ite) {
                //Log.i(logTag, "InvocationTargetException calling hasVibratorFunc");
            }
        } catch (NoSuchMethodException nsme) {
            //Log.i(logTag, "hasVibratorFunc not present even though SDK >= 11"); // should never happen
        }
    }
    return hasVibrator ? vibrator : null;
}

From source file:ar.com.martinrevert.argenteam.GcmIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *//* w w  w . ja v  a2s .  co  m*/
private void generarNotification(Context context, String message, String urlimagen, String urlarticulo,
        String tipo, String fecha) {
    SharedPreferences preferencias = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    boolean vib = preferencias.getBoolean("vibraoff", false);
    boolean movieoff = preferencias.getBoolean("movieoff", false);
    boolean tvoff = preferencias.getBoolean("tvoff", false);
    String ringmovie = preferencias.getString("prefRingtonemovie", "");
    String ringtv = preferencias.getString("prefRingtonetv", "");
    //Todo traducir ticker
    String ticker = "Nuevo subttulo " + tipo + " en aRGENTeaM";

    Random randomGenerator = new Random();
    int randomInt = randomGenerator.nextInt(100);

    Bitmap bitmap = getRemoteImage(urlimagen, tipo);

    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    int dash = 500;
    int short_gap = 200;

    long[] pattern = { 0, // Start immediately
            dash, short_gap, dash, short_gap, dash };

    Intent notificationIntent;
    String ringtone;
    int ledlight;

    if (tipo.equalsIgnoreCase("Movie")) {
        ringtone = ringmovie;
        notificationIntent = new Intent(context, Peli.class);
        ledlight = preferencias.getInt("ledMovie", 0);

    } else {
        notificationIntent = new Intent(context, Tv.class);
        ringtone = ringtv;
        ledlight = preferencias.getInt("ledTV", 0);
        System.out.println(ledlight);
    }
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("passed", urlarticulo);

    PendingIntent pendingIntent;

    pendingIntent = PendingIntent.getActivity(context, randomInt, notificationIntent, 0);

    Notification myNotification;
    myNotification = new NotificationCompat.Builder(context).setPriority(1).setContentTitle(message)
            .setTicker(ticker).setLights(ledlight, 300, 300).setWhen(System.currentTimeMillis())
            .setContentIntent(pendingIntent).setSound(Uri.parse(ringtone)).setAutoCancel(true)
            .setSmallIcon(R.drawable.ic_stat_ic_argenteam_gcm).build();

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        RemoteViews views;
        views = new RemoteViews(getPackageName(), R.layout.custom_notification);
        views.setImageViewBitmap(R.id.big_picture, bitmap);
        views.setImageViewBitmap(R.id.big_icon,
                BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_ic_argenteam_gcm));
        views.setTextViewText(R.id.title, message);
        myNotification.bigContentView = views;
    }

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

    if (movieoff && tipo.equalsIgnoreCase("Movie")) {
        if (vib) {
            v.vibrate(pattern, -1);
        }
        notificationManager.notify(randomInt, myNotification);

    }

    if (tvoff && tipo.equalsIgnoreCase("Serie TV")) {
        if (vib) {
            v.vibrate(pattern, -1);
        }
        notificationManager.notify(randomInt, myNotification);

    }

}

From source file:com.daiv.android.twitter.services.SendScheduledTweet.java

public void finishedTweetingNotification() {
    try {/*from  w w w.  j  a  v a2  s .  c o m*/
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(MainActivity.sContext)
                .setSmallIcon(R.drawable.ic_stat_icon)
                .setContentTitle(getResources().getString(R.string.tweet_success)).setOngoing(false)
                .setTicker(getResources().getString(R.string.tweet_success));

        if (AppSettings.getInstance(this).vibrate) {
            Log.v(TAG + "Test_vibrate", "vibrate on compose");
            Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            long[] pattern = { 0, 50, 500 };
            v.vibrate(pattern, -1);
        }

        stopForeground(true);

        NotificationManager mNotificationManager = (NotificationManager) MainActivity.sContext
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(6, mBuilder.build());
        // cancel it immediately, the ticker will just go off
        mNotificationManager.cancel(6);
    } catch (Exception e) {
        // not attached to activity
    }
}

From source file:com.daiv.android.twitter.services.SendQueue.java

public void finishedTweetingNotification() {
    try {//from www  .j a  va 2  s .co m
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(MainActivity.sContext)
                .setSmallIcon(R.drawable.ic_stat_icon)
                .setContentTitle(getResources().getString(R.string.tweet_success)).setOngoing(false)
                .setTicker(getResources().getString(R.string.tweet_success));

        if (AppSettings.getInstance(this).vibrate) {
            Log.v(TAG + "Test_vibrate", "vibrate on compose");
            Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            long[] pattern = { 0, 50, 500 };
            v.vibrate(pattern, -1);
        }

        stopForeground(true);

        NotificationManager mNotificationManager = (NotificationManager) MainActivity.sContext
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(6, mBuilder.build());
        // cancel it immediately, the ticker will just go off
        mNotificationManager.cancel(6);

        sendMessage();
    } catch (Exception e) {
        // not attached to activity
    }
}

From source file:com.tfc.webviewer.presenter.WebViewPresenterImpl.java

@Override
public void onLongClick(WebView.HitTestResult result) {
    Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(mContext.getResources().getInteger(R.integer.vibrator_duration));

    int type = result.getType();
    final String extra = result.getExtra();

    switch (type) {
    case WebView.HitTestResult.EMAIL_TYPE: {
        CharSequence[] items = new CharSequence[] { mContext.getString(R.string.send_email),
                mContext.getString(R.string.copy_email), mContext.getString(R.string.copy_link_text) };
        AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle(extra)
                .setItems(items, new DialogInterface.OnClickListener() {
                    @Override/*w  w w  .  j  a v a 2 s. c  o m*/
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                            mView.openEmail(extra);
                        } else if (which == 1 || which == 2) {
                            mView.copyLink(extra);
                            mView.showToast(makeToast(mContext.getString(R.string.message_copy_to_clipboard)));
                        }
                    }
                }).create();
        dialog.show();

        break;
    }
    case WebView.HitTestResult.GEO_TYPE: {
        Log.d(TAG, "geo longclicked");

        break;
    }
    case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
    case WebView.HitTestResult.IMAGE_TYPE: {
        CharSequence[] items = new CharSequence[] { mContext.getString(R.string.copy_link),
                mContext.getString(R.string.save_link), mContext.getString(R.string.save_image),
                mContext.getString(R.string.open_image) };
        AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle(extra)
                .setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                            mView.copyLink(extra);
                            mView.showToast(makeToast(mContext.getString(R.string.message_copy_to_clipboard)));
                        } else if (which == 1) {
                            mView.onDownloadStart(extra);
                        } else if (which == 2) {
                            mView.onDownloadStart(extra);
                        } else if (which == 3) {
                            mView.openPopup(extra);
                        }
                    }
                }).create();
        dialog.show();

        break;
    }
    case WebView.HitTestResult.PHONE_TYPE:
    case WebView.HitTestResult.SRC_ANCHOR_TYPE: {
        CharSequence[] items = new CharSequence[] { mContext.getString(R.string.copy_link),
                mContext.getString(R.string.copy_link_text), mContext.getString(R.string.save_link) };
        AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle(extra)
                .setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                            mView.copyLink(extra);
                            mView.showToast(makeToast(mContext.getString(R.string.message_copy_to_clipboard)));
                        } else if (which == 1) {
                            mView.copyLink(extra);
                            mView.showToast(makeToast(mContext.getString(R.string.message_copy_to_clipboard)));
                        } else if (which == 2) {
                            mView.onDownloadStart(extra);
                        }
                    }
                }).create();
        dialog.show();

        break;
    }
    }
}

From source file:com.tobolkac.triviaapp.ScreenSlideActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);
    Bundle b = getIntent().getExtras();/*from www .jav  a  2s  . com*/
    Parse.initialize(this, "paHnFob0MGoBuy16Pzg5YPCH6TMOZfgZPXEOY1em",
            "1WOoBPDmOAu9CbHfvKIGmNIt2mY32mEvBYoLcPLV");
    ParseAnalytics.trackAppOpened(getIntent());
    //        questionNums = b.getIntArray("questionsNumArray");
    //        cat = b.getString("category");
    timerTextView = (TextView) findViewById(R.id.gameTimer);
    timerTextView.setText("2:00");
    cdt.start();

    //set up vibrator
    vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    //Challenging (Creating Game)
    if (b.getString("com.parse.Data") == null && b.getString("gameId") == null) {
        isChallenger = true;
        //          userList.setText("Challenging");
        challengedUser = getIntent().getStringExtra("opponentName");
        cat = b.getString("category");
        Log.d("category", "category: " + cat);
        questionNums = getIntent().getIntegerArrayListExtra("questionNumArray");

        //query to batch retrieve questions
        ParseQuery<ParseObject> queryQuestions = ParseQuery.getQuery("Questions");
        queryQuestions.whereEqualTo("category", cat);
        queryQuestions.whereContainedIn("categoryIndex", questionNums);
        /*queryQuestions.findInBackground(new FindCallback<ParseObject>() {
                
        @Override
        public void done(List<ParseObject> objects, ParseException e) {
          Log.d("questions retrieved", "number: " + objects.size());
          questions = objects;
        }
        });*/

        correctArray = new int[questionNums.size()];
        for (int i = 0; i < correctArray.length; i++) {
            correctArray[i] = 0;
        }
        try {
            questions = queryQuestions.find();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Log.d("questionNums after",
                "In ScrrenSlideActivity: " + questionNums.toString() + " " + questions.size());

    } else {
        //Being Challenged (From Homescreen)
        if (b.getString("gameId") != null) {
            gameId = b.getString("gameId");
        } else {
            try {
                JSONObject data = new JSONObject(b.getString("com.parse.Data"));
                gameId = data.getString("gameId");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        isChallenger = false;

        ParseQuery<ParseObject> query = ParseQuery.getQuery("Games");
        try {
            ParseObject gameObj = query.get(gameId);
            challenger = gameObj.getString("challenger");
            opponent = gameObj.getString("opponent");
            cat = gameObj.getString("category");
            //getting question array from game object
            JSONArray q = gameObj.getJSONArray("questionsArray");
            Log.d("Json array", "length: " + q.length());
            ArrayList<Integer> stuff = new ArrayList<Integer>();
            for (int s = 0; s < q.length(); s++) {
                stuff.add((Integer) q.get(s));
            }

            Log.d("opponent questions Array", stuff.toString());

            //query to grab questions by category and number
            ParseQuery<ParseObject> queryQuestions = ParseQuery.getQuery("Questions");
            queryQuestions.whereEqualTo("category", cat);
            queryQuestions.whereContainedIn("categoryIndex", stuff);

            correctArray = new int[stuff.size()];
            for (int i = 0; i < correctArray.length; i++) {
                correctArray[i] = 0;
            }
            try {
                questions = queryQuestions.find();
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (ParseException e1) {
            e1.printStackTrace();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);
    FragmentManager manager = getSupportFragmentManager();
    mPagerAdapter = new ScreenSlidePagerAdapter(manager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            return true;
        }
    });
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When changing pages, reset the action bar actions since they are dependent
            // on which page is currently active. An alternative approach is to have each
            // fragment expose actions itself (rather than the activity exposing actions),
            // but for simplicity, the activity provides the actions in this sample.

            questionProgress.setCorrectArray(correctArray);
            questionProgress.setNumCorrect(position + 1);

            invalidateOptionsMenu();
        }
    });

    timerTextView = (TextView) findViewById(R.id.gameTimer);
    startTime = System.currentTimeMillis();

    questionProgress = ((CorrectQuestionView) findViewById(R.id.questionProgress));
    questionProgress.setQuestionProgress(true);
    questionProgress.setNumCorrect(1);
    questionProgress.setCorrectArray(correctArray);

}

From source file:com.spydiko.rotationmanager.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myapp = (AppSpecificOrientation) getApplication();
    setContentView(R.layout.activity_main);
    myapp.chechForUpdate(this);
    if (AppSpecificOrientation.appflood) {
        AppFlood.initialize(this, "4oxXbIyVm6xNiizl", "TbcZgeJj2facL52e003c9", AppFlood.AD_ALL);
        //      AppFlood.showBanner(this,AppFlood.BANNER_POSITION_BOTTOM,AppFlood.BANNER_SMALL);
        AppFlood.preload(AppFlood.AD_ALL, new AFRequestDelegate() {
            @Override/*from   w w  w .  j a v  a 2  s  .c  o  m*/
            public void onFinish(JSONObject arg0) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        //                  Toast.makeText(MainActivity.this, "preload finish", Toast.LENGTH_SHORT).show();
                        AFBannerView afBannerView = (AFBannerView) findViewById(R.id.banner);
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        afBannerView.setVisibility(View.VISIBLE);
                    }
                });
            }
        });
    }
    // Initialize everything
    /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      ActionBar actionBar = getActionBar();
    ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#00FEBB31"));
    actionBar.setBackgroundDrawable(colorDrawable);
    }*/

    //      AppFlood.initialize(this, "1lfdyfOzKDcLPRPu", "th4j61EB18bdL522870c8", AppFlood.AD_ALL);
    names = new ArrayList<String>();
    //      if (myapp.loadDonate("appflood2")) AppFlood.showFullScreen(this);
    myapp.configureAdColony(this);
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
    menu.setMenu(R.layout.slidingmenu);
    buttonClearAll = (Button) findViewById(R.id.button2);
    vibe = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    orientationButton = (ImageView) findViewById(R.id.orientationButton);
    globalOrientation = (LinearLayout) findViewById(R.id.globalOrientation);
    autoRotate = (TextView) findViewById(R.id.orientationText);
    activities = new ArrayList<Model>();
    lv = (ListView) findViewById(R.id.appList);
    final ArrayList<Model> data = (ArrayList<Model>) getLastNonConfigurationInstance();
    // Set Listeners
    orientationButton.setOnClickListener(this);
    buttonClearAll.setOnClickListener(this);
    if (AppSpecificOrientation.getCheck_button() == 0 || AppSpecificOrientation.getCheck_button() == 1) {
        if (Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.auto_rotate_on));
            autoRotate.setTextColor(Color.GREEN);
            autoRotate.setText(getResources().getText(R.string.orientationOn));
            AppSpecificOrientation.setCheck_button(0);
        } else {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.auto_rotate_off));
            autoRotate.setTextColor(Color.RED);
            autoRotate.setText(getResources().getText(R.string.orientationOff));
            AppSpecificOrientation.setCheck_button(1);
        }
    } else {
        if (AppSpecificOrientation.getCheck_button() == 2) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_portrait));
            autoRotate.setTextColor(Color.CYAN);
            autoRotate.setText(getResources().getText(R.string.forced_portrait));
        } else if (AppSpecificOrientation.getCheck_button() == 3) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_landscape));
            autoRotate.setTextColor(Color.CYAN);
            autoRotate.setText(getResources().getText(R.string.forced_landscape));
        } else if (AppSpecificOrientation.getCheck_button() == 4) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_auto));
            autoRotate.setTextColor(Color.parseColor("#FFFFFF"));
            autoRotate.setText(getResources().getText(R.string.forced_auto));
        }
    }
    // Register Content Observer
    getContentResolver().registerContentObserver(
            Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, rotationObserver);
    // Fill the list
    if (data == null) { // List not stored
        if (AppSpecificOrientation.LOG)
            Log.d(TAG, "null");
        packageManager = getPackageManager();
        this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication());
        lv.setAdapter(adapter);
        UpdateData updateData = new UpdateData();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            updateData.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
        else
            updateData.execute((Void[]) null);
    } else { // List stored
        if (AppSpecificOrientation.LOG)
            Log.d(TAG, "ok");
        activities = data;
        buttonsLayout = (LinearLayout) findViewById(R.id.twoButtons);
        progBar = (LinearLayout) findViewById(R.id.channelsProgress);
        this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication());
        lv.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        for (Model mdl : activities) {
            names.add(mdl.getPackageName());
        }
        progBar.setVisibility(View.GONE);
        lv.setVisibility(View.VISIBLE);
        buttonsLayout.setVisibility(View.VISIBLE);
        globalOrientation.setVisibility(View.VISIBLE);
    }
}