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.cloudbees.gasp.activity.ReviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    try {// ww w.  j  a  v  a2  s  .  c o m
        SharedPreferences gaspSharedPreferences = PreferenceManager
                .getDefaultSharedPreferences(getApplicationContext());
        mGaspUrl = new URL(gaspSharedPreferences.getString(getString(R.string.gasp_server_uri_preferences), "")
                + getString(R.string.gasp_reviews_location));

        Intent intent = getIntent();
        mRestaurantName = intent.getStringExtra(REVIEW_RESTAURANT_NAME);
        mGaspRestaurantId = intent.getIntExtra(REVIEW_RESTAURANT_ID, 0);
        mPlacesReference = intent.getStringExtra(REVIEW_REFERENCE);

        setContentView(R.layout.gasp_add_review_layout);
        setViews();
        addGaspFragments();
        addButtonListener();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.androidquery.simplefeed.PQuery.java

public void result(Activity act, int resultCode, Intent data) {

    Intent input = act.getIntent();

    if (input != null) {
        data.putExtra(FW_CB, input.getStringExtra(FW_CB));
        data.putExtra(FW_ID, input.getIntExtra(FW_ID, -1));
    }/*from ww w . j a v  a  2 s . co m*/

    act.setResult(resultCode, data);

}

From source file:com.gigathinking.simpleapplock.Upgrade.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 777) {
        if (resultCode == RESULT_OK) {
            int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
            String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
            String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
            if (responseCode == 0) {
                try {
                    JSONObject jo = new JSONObject(purchaseData);
                    String sku = jo.getString("productId");
                    if (sku.equals("no_ads")) {
                        mPrefs.edit().putBoolean("no_ads_purchased", true).commit();
                    }/*w  w  w  .  j a  v a2s. co  m*/
                    if (sku.equals("adv_prot")) {
                        mPrefs.edit().putBoolean("adv_prot_purchased", true).commit();
                    }
                    Toast.makeText(this, getString(R.string.upgrage_on_next_restart), Toast.LENGTH_LONG).show();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:ch.ethz.twimight.activities.ShowTweetListActivity.java

/**
 * On resume/*from w ww.  j a  va 2 s. c  o  m*/
 */
@Override
public void onResume() {

    super.onResume();
    running = true;

    Intent intent = getIntent();

    if (intent.hasExtra(FILTER_REQUEST)) {
        viewPager.setCurrentItem(intent.getIntExtra(FILTER_REQUEST, TweetListFragment.TIMELINE_KEY));
        intent.removeExtra(FILTER_REQUEST);

    }

}

From source file:com.grass.caishi.cc.service.BaseIntentService.java

/**
 * You should not override this method for your IntentService. Instead,
 * override {@link #onHandleIntent}, which the system calls when the
 * IntentService receives a start request.
 * /*w  ww. j  a  v  a2 s. c  o m*/
 * @see android.app.Service#onStartCommand
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        int ddo = intent.getIntExtra("do", 0);
        if (ddo != 0) {
            SendBean send = (SendBean) intent.getSerializableExtra("send");

            Message msg = mServiceHandler.obtainMessage();
            msg.arg1 = send.getSend_id();
            msg.what = send.getSend_id();
            Bundle b = new Bundle();
            b.putSerializable("send", send);
            msg.setData(b);
            // filelist.add(send);
            mServiceHandler.sendMessage(msg);
            intent.putExtra("do", UP_ADD);
            sendBroadcast(intent);
        }
    }

    return START_NOT_STICKY;
}

From source file:com.android.gallery3d.gadget.WidgetConfigure.java

private void setWidgetType(Intent data) {
    int widgetType = data.getIntExtra(KEY_WIDGET_TYPE, R.id.widget_type_shuffle);
    if (widgetType == R.id.widget_type_album) {
        Intent intent = new Intent(this, AlbumPicker.class);
        startActivityForResult(intent, REQUEST_CHOOSE_ALBUM);
    } else if (widgetType == R.id.widget_type_shuffle) {
        WidgetDatabaseHelper helper = new WidgetDatabaseHelper(this);
        try {/*from   w  w w.  j a  v a2  s .  co m*/
            helper.setWidget(mAppWidgetId, WidgetDatabaseHelper.TYPE_SHUFFLE, null, null);
            updateWidgetAndFinish(helper.getEntry(mAppWidgetId));
        } finally {
            helper.close();
        }
    } else {
        // Explicitly send the intent to the DialogPhotoPicker
        Intent request = new Intent(this, DialogPicker.class).setAction(Intent.ACTION_GET_CONTENT)
                .setType("image/*");
        startActivityForResult(request, REQUEST_GET_PHOTO);
    }
}

From source file:com.alchemiasoft.book.service.BookActionService.java

@Override
protected void onHandleIntent(Intent intent) {
    final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, NOT_VALID_NOTIFICATION);
    // Cancelling any shown notification
    if (notificationId != NOT_VALID_NOTIFICATION) {
        Log.d(TAG_LOG, "Dismissing notification with id=" + notificationId);
        NotificationManagerCompat.from(this).cancel(notificationId);
    }//w w  w.j ava  2s . c  o  m
    final long bookId = intent.getLongExtra(EXTRA_BOOK_ID, NOT_VALID_BOOK);
    if (bookId != NOT_VALID_BOOK) {
        final ContentResolver cr = getContentResolver();
        final Action action = Action.valueOf(intent.getAction());
        Log.d(TAG_LOG, "Performing action=" + action + " on book with id=" + bookId);
        final ContentValues cv = new ContentValues();
        switch (action) {
        case BUY:
            cv.put(BookDB.Book.OWNED, 1);
            if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1
                    && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) {
                final Book book = getBook(bookId);
                if (book != null) {
                    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
                    builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
                            .setContentTitle(getString(R.string.book_purchased))
                            .setContentText(book.getTitle());
                    builder.setContentIntent(PendingIntent.getActivity(this, 0,
                            HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT));

                    // ONLY 4 WEARABLE(s)
                    final NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
                    wearableExtender
                            .setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.background));
                    // ACTION TO SELL A BOOK FROM A WEARABLE
                    final PendingIntent sellIntent = PendingIntent.getService(
                            this, 0, BookActionService.IntentBuilder.sell(this, book)
                                    .notificationId(NOTIFICATION_ID).wearableInput().build(),
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    wearableExtender.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_action_sell,
                            getString(R.string.action_sell), sellIntent).build());
                    // Finally extending the notification
                    builder.extend(wearableExtender);

                    NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build());
                }
            }
            break;
        case SELL:
            cv.put(BookDB.Book.OWNED, 0);
            if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1
                    && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) {
                final Book book = getBook(bookId);
                if (book != null) {
                    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
                    builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
                            .setContentTitle(getString(R.string.book_sold)).setContentText(book.getTitle());
                    builder.setContentIntent(PendingIntent.getActivity(this, 0,
                            HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT));

                    NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build());
                }
            }
            break;
        case ADD_NOTE:
            final CharSequence notes = getExtraNotes(intent);
            if (!TextUtils.isEmpty(notes)) {
                cv.put(BookDB.Book.NOTES, notes.toString());
                cr.update(BookDB.Book.create(bookId), cv, null, null);
            }
            break;
        default:
            break;
        }
    }
}

From source file:fr.eyal.lib.data.service.DataLibService.java

@SuppressWarnings("unchecked")
@Override//from w  ww  .jav a2s. c  o m
protected void onHandleIntent(final Intent intent) {
    final int processorType = intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1);

    Out.d(TAG, "onHandleIntent");

    //      String userAgent = intent.getStringExtra(INTENT_EXTRA_USER_AGENT);

    final DataLibRequest request = new DataLibRequest();
    DataLibWebConfig.applyToRequest(request, DataLibWebConfig.getInstance()); //we apply a default configuration for the request

    //we get the action data
    request.url = intent.getStringExtra(INTENT_EXTRA_URL);
    request.params = intent.getParcelableExtra(INTENT_EXTRA_PARAMS);
    request.parseType = intent.getIntExtra(INTENT_EXTRA_PARSE_TYPE, DataLibRequest.PARSE_TYPE_SAX_XML);

    //we eventually add the complex options
    Object complexOptions = intent.getSerializableExtra(INTENT_EXTRA_COMPLEX_OPTIONS);
    if (complexOptions instanceof ComplexOptions)
        request.complexOptions = (ComplexOptions) complexOptions;

    request.context = getApplicationContext();
    //we get the options to apply
    int option = intent.getIntExtra(INTENT_EXTRA_REQUEST_OPTION, DataLibRequest.OPTION_NO_OPTION);
    DataLibWebConfig.applyToRequest(request, option, true);

    //we add the intent
    request.intent = intent;

    try {

        if (processorType == COOKIES_FLUSH)
            this.flushCookies();

        else {
            //we launch the processor on a daughter class
            launchProcessor(processorType, request);
        }

    } catch (final Exception e) {
        Out.e(TAG, "Erreur", e);
        final BusinessResponse response = new BusinessResponse();
        response.status = BusinessResponse.STATUS_ERROR;
        response.statusMessage = Log.getStackTraceString(e);
        sendResult(request, response, response.status);
    }

}

From source file:com.lepin.activity.AddNewCarActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == 5) {
        String cartype = data.getStringExtra("cartype");
        carTypeId = String.valueOf(data.getIntExtra("typeId", 0));
        addCarType.setText(cartype);//  w w  w  . j a  v  a 2  s  .  co m
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:ca.spencerelliott.mercury.ChangesetService.java

@Override
public void onStart(Intent intent, int startId) {
    int broadcast_call = intent.getIntExtra("ca.spencerelliott.mercury.call", -1);

    //If this was on boot we want to set up the alarm to set up repeating notifications
    if (broadcast_call == AlarmReceiver.ON_BOOT) {
        //Get the alarm service
        AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

        //Generate the interval between notifications, default to fifteen minutes
        long interval = Long.parseLong(prefs.getString("notification_interval", "900000"));

        //Create the intents to launch the service again
        Intent new_intent = new Intent("ca.spencerelliott.mercury.REFRESH_CHANGESETS");
        PendingIntent p_intent = PendingIntent.getBroadcast(this, 0, new_intent, 0);

        final Calendar c = Calendar.getInstance();

        //Create a repeating alarm
        alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, c.getTimeInMillis() + interval,
                interval, p_intent);/*from ww  w.  jav a  2  s.  c o m*/

        //Stop the service since we're waiting for the interval
        stopSelf();
    }

    //Create a new feed processor
    FeedProcessor processor = new FeedProcessor();

    //Gather all of the URLs from the databases here

    //Let the processor handle all of the URLs and notify the user of any new changesets
    processor.execute();

}