Example usage for android.content Intent getIntExtra

List of usage examples for android.content Intent getIntExtra

Introduction

In this page you can find the example usage for android.content Intent getIntExtra.

Prototype

public int getIntExtra(String name, int defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.android.deskclock2.DeskClock.java

@Override
public void onNewIntent(Intent newIntent) {
    super.onNewIntent(newIntent);
    LogUtils.d(TAG, "onNewIntent with intent: %s", newIntent);

    // update our intent so that we can consult it to determine whether or
    // not the most recent launch was via a dock event
    setIntent(newIntent);//  w  w  w  . ja  v a2 s .co  m

    // Honor the tab requested by the intent, if any.
    int tab = newIntent.getIntExtra(SELECT_TAB_INTENT_EXTRA, -1);
    if (tab != -1 && mTabLayout != null) {
        mTabLayout.getTabAt(tab).select();
        mViewPager.setCurrentItem(tab);
    }
}

From source file:com.amaze.filemanager.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS");
    String FILE2 = intent.getStringExtra("COPY_DIRECTORY");
    int mode = intent.getIntExtra("MODE", 0);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt("id", startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))

            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);
    if (foreground) {
        startForeground(Integer.parseInt("456" + startId), mBuilder.build());
        foreground = false;/*from   w  w w .j a  va  2  s.  c o m*/
    }
    b.putBoolean("move", intent.getBooleanExtra("move", false));
    b.putString("FILE2", FILE2);
    b.putInt("MODE", mode);
    b.putParcelableArrayList("files", files);
    hash.put(startId, true);
    DataPackage intent1 = new DataPackage();
    intent1.setName(files.get(0).getName());
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setP2(0);
    intent1.setMove(intent.getBooleanExtra("move", false));
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.att.arocollector.AROCollectorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate(...)");
    // Setup handler for uncaught exceptions.
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override//from  ww  w .  j a  va2  s.  c o  m
        public void uncaughtException(Thread thread, Throwable e) {
            handleUncaughtException(thread, e);
        }
    });

    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    final TextView splashText = (TextView) findViewById(R.id.splash_message);
    splashText.setText(String.format(getString(R.string.splashmessageopensource),
            getString(R.string.app_brand_name), getString(R.string.app_url_name)));
    AttenuatorManager.getInstance().init();
    Intent intent = getIntent();
    //delay
    int delayDl = intent.getIntExtra(BundleKeyUtil.DL_DELAY, 0);
    int delayUl = intent.getIntExtra(BundleKeyUtil.UL_DELAY, 0);

    if (delayDl >= 0) {
        AttenuatorManager.getInstance().setDelayDl(delayDl);
    } else {
        Log.i(TAG, "Invalid attenuation delay value" + delayDl + "ms");
    }

    if (delayUl >= 0) {
        AttenuatorManager.getInstance().setDelayUl(delayUl);
    } else {
        Log.i(TAG, "Invalid attenuation delay value" + delayUl + "ms");
    }

    //throttle
    int throttleDl = intent.getIntExtra(BundleKeyUtil.DL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED);
    int throttleUl = intent.getIntExtra(BundleKeyUtil.UL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED);

    AttenuatorManager.getInstance().setThrottleDL(throttleDl);
    Log.d(TAG, "Download speed throttle value: " + throttleDl + " kbps");

    AttenuatorManager.getInstance().setThrottleUL(throttleUl);
    Log.d(TAG, "Upload speed throttle value: " + throttleUl + " kbps");

    printLog = intent.getBooleanExtra(BundleKeyUtil.PRINT_LOG, false);

    setVideoOption(intent);

    bitRate = intent.getIntExtra(BundleKeyUtil.BIT_RATE, 0);
    String screenSizeTmp = intent.getStringExtra(BundleKeyUtil.SCREEN_SIZE);
    screenSize = screenSizeTmp == null ? screenSize : screenSizeTmp;

    setVideoOrient(intent);

    Log.i(TAG,
            "get from intent delayTime: " + AttenuatorManager.getInstance().getDelayDl()
                    + "get from intent delayTimeUL: " + AttenuatorManager.getInstance().getDelayUl()
                    + "get from intent throttleDL: " + AttenuatorManager.getInstance().getThrottleDL()
                    + "get from intnetn throttleUL: " + AttenuatorManager.getInstance().getThrottleUL()
                    + " video: " + videoOption + " bitRate: " + bitRate + " screenSize: " + screenSize
                    + " orientation: " + videoOrient);

    context = getApplicationContext();
    launchAROCpuTraceService();
    launchAROCpuTempService();
    if (networkAndAirplaneModeCheck()) {

        // register to listen for close down message
        registerAnalyzerCloseCmdReceiver();
        Log.d(TAG, "register the attenuator delay signal");

        startVPN();
    }

    { // test code
        PackageInfo packageInfo = null;
        try {
            packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        boolean valu = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        // build datetime
        Date buildDate = new Date(BuildConfig.TIMESTAMP);
        String appBuildDate = "";
        if (buildDate != null) {
            appBuildDate = buildDate.toString();
        }

        String display = "App Build Date: " + appBuildDate + "\n"
        //               +" DownStream Delay Time: " + AttenuatorManager.getInstance().getDelayDl() + " ms\n"
        //               +" UpStream Delay Time: " + AttenuatorManager.getInstance().getDelayUl() + " ms\n"
        //               +" DownStream Throttle: " + AttenuatorManager.getInstance().getThrottleDL() + " kbps\n"
        //               +" Upstream Throttle: " + AttenuatorManager.getInstance().getThrottleUL() + " kbps\n"
                + AttenuatorUtil.getInstance().notificationMessage() + "\n" + " Version: "
                + packageInfo.versionName + " (" + (valu ? "Debug" : "Production") + ")";

        ((TextView) findViewById(R.id.version)).setText(display);
    }
}

From source file:com.chao.facebookzc.UiLifecycleHelper.java

private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }// w ww  .jav  a2 s.  c o  m
    pendingFacebookDialogCall = null;
}

From source file:in.codehex.arrow.MainActivity.java

/**
 * Get the battery status of the device/* w w  w . j a  va2s.  c  o  m*/
 *
 * @return the battery level of the device
 */
private float getBatteryLevel() {
    Intent batteryIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    int level = -1, scale = -1;
    if (batteryIntent != null) {
        level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
    }

    // Error checking that probably isn't needed but I added just in case.
    if (level == -1 || scale == -1) {
        return 50.0f;
    }

    return ((float) level / (float) scale) * 100.0f;
}

From source file:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java

void initializeNfcStateChangeListener() {
    nfcStateChangeBroadcastReceiver = new BroadcastReceiver() {
        @Override//from w  w w  .ja v  a2 s  . c  om
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();

            if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) {
                final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF);

                switch (state) {
                case NfcAdapter.STATE_OFF:
                case NfcAdapter.STATE_TURNING_OFF:
                    onNfcDisabled();
                    break;
                case NfcAdapter.STATE_TURNING_ON:
                    break;
                case NfcAdapter.STATE_ON:
                    onNfcEnabled();
                    break;
                }
            }
        }
    };
}

From source file:edu.cnu.PowerTutor.ui.PowerViewer.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    switch (requestCode) {
    case 0://from  w  w  w  . ja  v a 2s . com
        if (resultCode == RESULT_OK) {
            SeletedUid = data.getIntExtra("uid", 0);
            SeletedPackageName = data.getStringExtra("package_name");
            Toast.makeText(PowerViewer.this, "Extra Data: " + SeletedUid + " " + SeletedPackageName,
                    Toast.LENGTH_SHORT).show();

            //  ? ? ?? ? ??   .
            //   ? ??   ? ? .
            saveProgress(PROGRESS_MAX); //   ? .

            //   Thread?? ?? Server  Thread?.
            processResultThread mProcessResultThread = new processResultThread();

            // Thread  .
            mProcessResultThread.start();
            Log.d(TAG, "Thread start pass");
        }
        break;
    }
}

From source file:com.z.stproperty.PropertyDetail.java

/***
 * @Param requestCode : Request code to identify the calling function
 * @param resultCode/* www.j  a v a 2s. co  m*/
 *            : Response returned from the called function RESULT_OK or
 *            RESULT_CANCEL
 * @param data
 *            : Is an intent extra values passed from called function
 * 
 *            Exit dialog return values handled
 * 
 * For sharing and settings this will get called on activity returns the result 
 * back to this activity on successful completion
 */
@Override
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
    super.onActivityResult(arg0, arg1, arg2);
    if (arg1 == RESULT_CANCELED && arg0 == Constants.REQUESTCODE_SETTINGS) {
        finish();
    } else if (arg1 == RESULT_OK) {
        if (arg0 == Constants.REQUESTCODE_SETTINGS) {
            dialog.show();
            checkUpdate();
        } else {
            int id = arg2.getIntExtra("id", 0);
            switch (id) {
            case 0:
                new ShareWithfacebook(PropertyDetail.this, title, shareImageLink, description, prurl);
                SharedFunction.postAnalytics(PropertyDetail.this, "Lead", "Facebook Share", title);
                break;
            case 1:
                shareWithTwitter();
                break;
            case 2:
                shareWithEmail();
                break;
            default:
                break;
            }
        }
    }
}

From source file:de.da_sense.moses.client.FormFragment.java

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);
    if (isVisibleToUser) {
        // oh I got selected, check if there is a message for me
        Intent activityIntent = getActivity().getIntent();
        int fragmentWhichShouldScroll = activityIntent.getIntExtra(KEY_POSITION_OF_FRAGMENT_WHICH_SHOULD_SCROLL,
                -1);//ww  w  . j  av a  2s. c  o  m
        if (fragmentWhichShouldScroll == mPosition) {
            // it is me who should scroll, get that question id
            int questionId = activityIntent.getIntExtra(KEY_QUESTION_TO_SCROLL_TO, -1);
            // find the question instance
            for (Question aQuestion : mQuestionTitleMappings.keySet())
                if (aQuestion.getId() == questionId) {
                    // we have found the question, now scroll to it
                    scrollToQuestion(aQuestion);
                    break;
                }
            // remove the information from the intent, because consumed by this FormFragment
            activityIntent.removeExtra(KEY_POSITION_OF_FRAGMENT_WHICH_SHOULD_SCROLL);
            activityIntent.removeExtra(KEY_QUESTION_TO_SCROLL_TO);
        }
    }
}

From source file:com.josephblough.sbt.activities.ShortcutActivity.java

/** Called when the activity is first created. */
@Override/*  w  w w  . j  a v  a  2  s . c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent intent = getIntent();
    final String action = intent.getAction();

    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        // Create a shortcut
        //ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
        ShortcutAdapter adapter = new ShortcutAdapter(this, R.layout.shortcut_type_row, ITEMS);
        setListAdapter(adapter);

        getListView().setOnItemClickListener(this);
    } else {
        // Perform the search
        final int searchType = intent.getIntExtra(SEARCH_TYPE, 0);
        final String criteria = intent.getStringExtra(CRITERIA);
        try {
            performSearch(searchType, criteria);
        } catch (JSONException e) {
            Log.e(TAG, e.getMessage(), e);
            Toast.makeText(this, "There was an error reading search criteria", Toast.LENGTH_LONG).show();
        }
    }

}