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.example.activity.FollowingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.followers_list);

    Intent intent = getIntent();
    playerId = intent.getIntExtra(PLAYER_ID, 1);
    playerName = intent.getStringExtra(PLAYER_NAME);

    title = (TextView) findViewById(R.id.topview_title);
    back = (ImageView) findViewById(R.id.topview_back);
    title.setText(playerName + "");
    back.setVisibility(View.VISIBLE);
    back.setOnClickListener(new OnClickListener() {

        @Override//from w  w w  .  j  a  va2s  .  c o m
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });

    xlistView = (XListView) findViewById(R.id.followers_listview);

    xlistView.setXListViewListener(this, 0);
    xlistView.setPullLoadEnable(true);
    xlistView.setRefreshTime();

    followingModel = new FollowingModel(this);
    followingModel.addResponseListener(this);
    followingModel.getFollowing(playerId);

}

From source file:com.example.activity.FollowersActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.followers_list);

    Intent intent = getIntent();
    playerId = intent.getIntExtra(PLAYER_ID, 1);
    playerName = intent.getStringExtra(PLAYER_NAME);

    title = (TextView) findViewById(R.id.topview_title);
    back = (ImageView) findViewById(R.id.topview_back);
    title.setText(playerName + "?");
    back.setVisibility(View.VISIBLE);
    back.setOnClickListener(new OnClickListener() {

        @Override//from w w  w  .  ja  va  2 s .  c  o m
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });

    xlistView = (XListView) findViewById(R.id.followers_listview);

    xlistView.setXListViewListener(this, 0);
    xlistView.setPullLoadEnable(true);
    xlistView.setRefreshTime();

    followersModel = new FollowersModel(this);
    followersModel.addResponseListener(this);
    followersModel.getFollowers(playerId);

}

From source file:com.bangz.smartmute.RuleEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    mMode = intent.getIntExtra(Constants.INTENT_EDITORNEW, Constants.INTENT_NEW);
    mUri = intent.getData();// ww w. jav a2  s.  c  om

    if (savedInstanceState == null) {
    } else {

    }

    if (mUri == null) {
        mMode = Constants.INTENT_NEW;
    } else {
        mMode = Constants.INTENT_EDIT;
        LoaderManager lm = getSupportLoaderManager();
        lm.initLoader(1, null, this);
    }

    showDoneCancelBar(true);

}

From source file:de.petendi.ethereum.android.EthereumAndroid.java

private void handleResponse(Intent reponse) {
    int id = reponse.getIntExtra(ID, 0);
    String error = reponse.getStringExtra(EXTRA_ERROR);
    byte[] response = reponse.getByteArrayExtra(EXTRA_DATA);
    if (error != null) {
        try {/*from  w ww.j  av a2 s  .c o m*/
            ServiceError errorObj = objectMapper.readValue(error, ServiceError.class);
            callback.handleError(id, errorObj);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    } else if (response != null) {
        try {
            WrappedResponse responseObj = objectMapper.readValue(response, WrappedResponse.class);
            callback.handleResponse(id, responseObj);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
}

From source file:com.andresrcb.gcmtest.LoggingService.java

private void doLog(Intent intent) {
    int priority = intent.getIntExtra(EXTRA_LOG_PRIORITY, Log.INFO);
    String msg = intent.getStringExtra(EXTRA_LOG_MESSAGE);

    // Make the log available through adb logcat
    Log.println(priority, LOG_TAG, msg);

    // Add the timestamp to the message
    String timestamp = dateFormat.format(new Date());
    msg = timestamp + " " + msg;

    // Forward the log to LocalBroadcast subscribers (i.e. UI)
    Intent localIntent = new Intent(ACTION_LOG);
    localIntent.putExtra(EXTRA_LOG_MESSAGE, msg);
    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);

    // Write log to file
    try {/*from  w ww  .j  ava2  s .  com*/
        FileOutputStream outputFile = openFileOutput(LOG_FILE, MODE_APPEND);
        outputFile.write(msg.getBytes());
        outputFile.write(LOG_SEPARATOR.getBytes());
        outputFile.close();
    } catch (IOException ex) {
        Log.e(LOG_TAG, "Error while writing in the log file", ex);
    }
}

From source file:anakiou.com.picontrol.service.InputIntentService.java

private void handleNameSet(Intent intent) {

    int no = intent.getIntExtra(Constants.EXTRA_NO, 0);

    for (Input in : inputDAO.findAll()) {
        if (in.getInputNumber() == no) {
            String name = inputService.setInputName(no, in.getName());

            if (name.equals(in.getName())) {
                deliverResultToReceiver(Constants.SUCCESS_RESULT, getString(R.string.saved));
            } else {
                deliverResultToReceiver(Constants.FAILURE_RESULT, getString(R.string.failed_to_set_name));
            }/*from w  w w . ja v  a  2  s.co m*/
            break;
        }
    }
}

From source file:cl.chihau.holaauto.MessageReplyReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "onReceive called");

    if (MyMessagingService.REPLY_ACTION.equals(intent.getAction())) {
        int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1);
        CharSequence reply = getMessageText(intent);
        Log.d(TAG, "Got reply (" + reply + ") for ConversationId " + conversationId);

        // Tell the Service to send another message.
        Intent serviceIntent = new Intent(context, MyMessagingService.class);
        serviceIntent.setAction(MyMessagingService.SEND_MESSAGE_ACTION);
        context.startService(serviceIntent);
    }/*from   w w  w.  ja v  a 2s. c om*/
}

From source file:com.android.tripgenie.auto.MessageReplyReceiver.java

@Override
public void onReceive(final Context context, Intent intent) {
    if (MessagingService.REPLY_ACTION.equals(intent.getAction())) {
        final int conversationId = intent.getIntExtra(MessagingService.CONVERSATION_ID, -1);
        CharSequence reply = getMessageText(intent);
        String response = "";
        if (conversationId != -1) {
            Log.d(TAG, "Got reply (" + reply + ") for ConversationId " + conversationId);

            //pass the reply to MasterBot
            MasterBot masterBot = MyApplication.getInstance().getMasterBot();

            BotRunnable botRunnable = new BotRunnable() {
                @Override/*from   w w w  .  j a  v  a 2s .  co m*/
                public void run() {
                    // Tell the Service to send another message.
                    Intent serviceIntent = new Intent(context, MessagingService.class);
                    serviceIntent.setAction(MessagingService.SEND_MESSAGE_ACTION);
                    if (!TextUtils.isEmpty(getData())) {
                        serviceIntent.putExtra("message", getData());
                    }
                    context.startService(serviceIntent);
                    Log.d(TAG, "Sending response for ConversationId " + conversationId);
                }
            };

            masterBot.process(String.valueOf(reply), botRunnable);

            //ApiHandler apiHandler = new ApiHandler();
            //apiHandler.handleUrl("reply");
        }
    }
}

From source file:com.concavenp.nanodegree.popularmoviesimproved.MovieReviewsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_movie_reviews);

    // This activity is not the home, so show the back arrow.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    mMovieId = intent.getIntExtra(EXTRA_DATA, DEFAULT_MOVIE_ID);

    // TODO: 1/23/2016 - error check for the DEFAULT_MOVIE_ID

    // Instantiate the RequestQueue.
    mRequestQueue = Volley.newRequestQueue(this);

    RecyclerView recyclerView = findViewById(R.id.reviews_RecyclerView);
    mAdapter = new ReviewsAdapter();
    recyclerView.setAdapter(mAdapter);//from ww w.java2 s.c o m
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.addOnScrollListener(new EndlessRecyclerOnScrollListener(linearLayoutManager) {
        @Override
        public void onLoadMore(int current_page) {
            requestData(current_page);
        }
    });
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    recyclerView.setHasFixedSize(true);

    // Make the first web request for page one of the data
    requestData(1);
}

From source file:com.gtdbrowser.data.service.GtdService.java

@Override
protected void onHandleIntent(final Intent intent) {
    final int workerType = intent.getIntExtra(INTENT_EXTRA_WORKER_TYPE, -1);
    String uri;/*ww  w  .j ava 2 s . co m*/
    Bundle resultBundle;

    try {
        switch (workerType) {
        case WORKER_TYPE_FILTERED_LIST:
            uri = intent.getStringExtra(INTENT_EXTRA_URI);
            resultBundle = FilteredListWorker.start(this, uri);
            sendSuccess(intent, resultBundle);
            break;
        case WORKER_TYPE_ATTACK_LIST:
            uri = intent.getStringExtra(INTENT_EXTRA_URI);
            resultBundle = AttackListWorker.start(this, uri);

            // Update the web service URI if there are more pages, otherwise
            // call it the end of pagination on this filter type.
            String ws_uri;
            if (resultBundle.getString("nextURI") != null)
                ws_uri = resultBundle.getString("nextURI");
            else
                ws_uri = END_PAGINATION;
            int total_count = resultBundle.getInt("total_count");

            SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString("attacks" + "_uri", ws_uri);
            editor.putInt("total_count", total_count);
            editor.commit();

            sendSuccess(intent, resultBundle);
            break;
        }
    } catch (final IllegalStateException e) {
        Log.e(LOG_TAG, "IllegalStateException", e);
        sendConnexionFailure(intent, null);
    } catch (final IOException e) {
        Log.e(LOG_TAG, "IOException", e);
        sendConnexionFailure(intent, null);
    } catch (final URISyntaxException e) {
        Log.e(LOG_TAG, "URISyntaxException", e);
        sendConnexionFailure(intent, null);
    } catch (final RestClientException e) {
        Log.e(LOG_TAG, "RestClientException", e);
        sendConnexionFailure(intent, null);
    } catch (final ParserConfigurationException e) {
        Log.e(LOG_TAG, "ParserConfigurationException", e);
        sendDataFailure(intent, null);
    } catch (final SAXException e) {
        Log.e(LOG_TAG, "SAXException", e);
        sendDataFailure(intent, null);
    } catch (final JSONException e) {
        Log.e(LOG_TAG, "JSONException", e);
        sendDataFailure(intent, null);
    }
    // This block (which should be the last one in your implementation)
    // will catch all the RuntimeException and send you back an error
    // that you can manage. If you remove this catch, the
    // RuntimeException will still crash the GtdService but you will not be
    // informed (as it is in 'background') so you should never remove this
    // catch
    catch (final RuntimeException e) {
        Log.e(LOG_TAG, "RuntimeException", e);
        sendDataFailure(intent, null);
    }
}