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.dashihui.afford.ui.activity.AtyFragmentDiscount.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_order_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??//  w  w  w  . j  a v a 2s.c o  m
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra(TABCODE, 0));
    tabs.setViewPager(pager);

    changeColor(currentColor);
}

From source file:com.cuddlesoft.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);/* ww  w .j a va 2 s .c o  m*/
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).run();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}

From source file:name.gumartinm.weather.information.widget.WidgetIntentService.java

@Override
protected void onHandleIntent(final Intent intent) {
    final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
            AppWidgetManager.INVALID_APPWIDGET_ID);
    final boolean isRefreshAppWidget = intent.getBooleanExtra("refreshAppWidget", false);

    if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        // Nothing to do. Something went wrong.
        return;/*from w  ww. ja va2 s .  com*/
    }

    final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
    final WeatherLocation weatherLocation = query.queryDataBase();

    if (weatherLocation == null) {
        // Nothing to do. Show error.
        final RemoteViews view = this.makeViewOnError(appWidgetId);
        this.updateWidget(view, appWidgetId);
        return;
    }

    if (!isRefreshAppWidget) {
        final RemoteViews view = this.makeViewOnNotRefresh(weatherLocation, appWidgetId);
        this.updateWidget(view, appWidgetId);
    } else {
        final RemoteViews view = this.makeViewOnRefresh(weatherLocation, appWidgetId);
        this.updateWidget(view, appWidgetId);
    }
}

From source file:com.remdo.app.WebViewActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_web_view);

    // Get the uri from the intent
    Intent intent = getIntent();
    String uriToDisplay = intent.getStringExtra("DEVICE_URL");
    String usr = intent.getStringExtra("DEVICE_USER");
    String pwd = intent.getStringExtra("DEVICE_PASSWORD");
    Integer odTypeId = intent.getIntExtra("DEVICE_ODTYPEID", -1);

    if (odTypeId == 1)//ODNetWork    
    {//from w w w. j a v a2  s.c  om
        if (!uriToDisplay.contains("cgi-bin/od.cgi")) {
            uriToDisplay = uriToDisplay.concat("/cgi-bin/od.cgi");
        }

        //initialize WebView
        webView = (WebView) findViewById(R.id.webView1);
        //we should define a webview client to get user navigation inside our webview otherwise 
        //defaul behaviour will open a webbrowser on first click
        webView.setWebViewClient(new WebViewClient());

        try {

            byte[] post = EncodingUtils.getBytes("USERNAME=" + usr + "&PASSWORD=" + pwd, "BASE64");
            webView.postUrl(uriToDisplay, post);

        } catch (Exception e) {
            String message = e.getMessage();
        }
    } else//ODControl
    {
        webView = (WebView) findViewById(R.id.webView1);

        webView.setHttpAuthUsernamePassword(uriToDisplay, "/", "user@opendomo.com", "opendomo");
        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new MyWebViewClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://local.opendomo.com");

    }

}

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

@Override
protected void onHandleIntent(Intent intent) {

    receiver = intent.getParcelableExtra(Constants.RECEIVER);

    if (!networkService.isNetworkAvailableAndConnected()) {

        deliverResultToReceiver(Constants.FAILURE_RESULT);

        return;/*from   w w w .  j a va 2  s  .  co m*/
    }

    int operationType = intent.getIntExtra(Constants.EXTRA_OPERATION_TYPE, 0);

    switch (operationType) {
    case Constants.OP_EVENT_LOG_GET_ALL:
        handleGetAll(intent);
        break;
    case Constants.OP_EVENT_LOG_GET:
        handleGet(intent);
        break;
    case Constants.OP_EVENT_LOG_COUNT:
        handleCount(intent);
    default:
    }
}

From source file:com.dashihui.afford.ui.activity.AtyFragmentOrdert.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_order_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("?");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerTab) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??//w  w  w. j  av a 2s  .c om
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra(TABCODE, 0));
    tabs.setViewPager(pager);
    tabs.setPosition(intent.getIntExtra(TABCODE, 0));

    LogUtils.e("position=============>" + intent.getIntExtra(TABCODE, 0));
    tabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i1) {
        }

        @Override
        public void onPageSelected(int i) {
            FragmentOrder fragmentOrder = FragmentOrder.newInstance(AtyFragmentOrdert.this, i);
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    });
}

From source file:com.dashihui.afford.ui.activity.AtyFragmentService.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aty_orderserver_frag);

    mTopTitle_txt = (TextView) findViewById(R.id.title);
    mTopTitle_txt.setText("??");
    mIbtnBack = (ImageButton) findViewById(R.id.ibtnBack);
    mIbtnBack.setOnClickListener(this);

    tabs = (WdtPagerSlidingTabStrip) findViewById(R.id.apps_fragment_tabs);
    pager = (ViewPager) findViewById(R.id.apps_fragment_viewpager);
    Intent intent = getIntent();
    //??1  2 ?? ???searchClassifyType
    mSearchClassifyType = intent.getIntExtra("searchClassifyType", -1);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    // ???N??/*  w w w  .  j  a v a2s  . co  m*/
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setCurrentItem(intent.getIntExtra("tabCode", 0));
    tabs.setViewPager(pager);

    changeColor(currentColor);
}

From source file:com.armtimes.activities.SingleArticlePreviewActivity.java

private void initActionBarTitle(final Intent intent, final ActionBar actionBar) {
    int title = R.string.app_name;
    try {//from  w  w w .jav a2  s.  c o m
        title = intent.getIntExtra(EXTRA_CATEGORY_TITLE_ID, 0);
    } finally {
        actionBar.setTitle(Html.fromHtml("<small>" + getResources().getString(title) + "</small>"));
        actionBar.setBackgroundDrawable(new ColorDrawable(0xFFFA294C));
    }
}

From source file:com.cyanogenmod.eleven.AhuButtonIntentReceiver.java

/**
 * {@inheritDoc}/*w  w w .j  a v a 2  s.c  om*/
 */
@Override
public void onReceive(final Context context, final Intent intent) {
    if (!MusicUtils.isPlaybackServiceConnected()) {
        if (DEBUG)
            Log.v(TAG, "Received intent: " + intent + ":" + intent.getAction() + ":"
                    + intent.getIntExtra("keyCode", 0) + " but no service running");
        return;
    }
    if (MusicPlaybackService.mBtLock) {
        if (DEBUG)
            Log.v(TAG, "Received intent: " + intent + ":" + intent.getAction() + ":"
                    + intent.getIntExtra("keyCode", 0) + " but BTLock is on!");
        return;
    }
    if (DEBUG)
        Log.v(TAG, "Received intent: " + intent + ":" + intent.getAction() + ":"
                + intent.getIntExtra("keyCode", 0));
    final String intentAction = intent.getAction();
    final int keyCode = intent.getIntExtra("keyCode", 0);

    if (ACTION_AHU_KEYDOWN.equals(intentAction)) {

        String command = null;
        String action = MusicPlaybackService.SERVICECMD;
        switch (keyCode) {
        case KEYCODE_AHU_BUTTON_STOP:
            command = MusicPlaybackService.CMDSTOP;
            break;

        case KEYCODE_AHU_BUTTON_PLAYPAUSE:
            command = MusicPlaybackService.CMDTOGGLEPAUSE;
            break;
        case KEYCODE_AHU_BUTTON_NEXT:
        case KEYCODE_AHU_BUTTON_NEXT_1:
        case KEYCODE_AHU_BUTTON_NEXT_2:
        case KEYCODE_AHU_BUTTON_NEXT_3:
            command = MusicPlaybackService.CMDNEXT;
            break;
        case KEYCODE_AHU_BUTTON_PREV:
        case KEYCODE_AHU_BUTTON_PREV_1:
        case KEYCODE_AHU_BUTTON_PREV_2:
        case KEYCODE_AHU_BUTTON_PREV_3:
            command = MusicPlaybackService.CMDPREVIOUS;
            break;
        case KEYCODE_AHU_BUTTON_REPEAT_MODE:
            action = MusicPlaybackService.REPEAT_ACTION;
            break;
        case KEYCODE_AHU_BUTTON_SETTRACK_0:
        case KEYCODE_AHU_BUTTON_SETTRACK_1:
        case KEYCODE_AHU_BUTTON_SETTRACK_2:
        case KEYCODE_AHU_BUTTON_SETTRACK_3:
        case KEYCODE_AHU_BUTTON_SETTRACK_4:
        case KEYCODE_AHU_BUTTON_SETTRACK_5:
        case KEYCODE_AHU_BUTTON_SETTRACK_6:
        case KEYCODE_AHU_BUTTON_SETTRACK_7:
        case KEYCODE_AHU_BUTTON_SETTRACK_8:
        case KEYCODE_AHU_BUTTON_SETTRACK_9:
            command = MusicPlaybackService.CMDSETTRACK;
            break;
        }
        if (command != null) {
            final Intent i = new Intent(context, MusicPlaybackService.class);
            i.setAction(action);
            i.putExtra(MusicPlaybackService.CMDNAME, command);
            if (MusicPlaybackService.CMDSETTRACK.equals(command)) {
                i.putExtra("track", keyCode - 282);
            }
            i.putExtra(MusicPlaybackService.FROM_AHU_BUTTON, true);
            context.startService(i);

        }

    }
}

From source file:com.wholegroup.rally.ScoreActivity.java

/** */
@Override/*from w  w w.  j  a v  a  2  s .c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //  ?  ? ??
    m_sbNumber = new StringBuffer();

    // ?
    Resources m_res = getResources();

    String[] arrDefaultNames = m_res.getStringArray(R.array.names);
    int[] arrDefaultScores = m_res.getIntArray(R.array.scores);

    m_arrRecords = new ScoreRecord[RECORDCOUNT];

    for (int i = 0; i < RECORDCOUNT; i++) {
        if ((i < arrDefaultNames.length) && (i < arrDefaultScores.length)) {
            m_arrRecords[i] = new ScoreRecord(arrDefaultNames[i], arrDefaultScores[i], Rally.GAME_A);
        } else {
            m_arrRecords[i] = new ScoreRecord(getString(R.string.score_default_name), 0, Rally.GAME_A);
        }
    }

    m_strGameA = getString(R.string.rally_text_short_game_a);
    m_strGameB = getString(R.string.rally_text_short_game_b);

    //   
    Intent intent = getIntent();

    m_iScore = intent.getIntExtra(getString(R.string.score_parameter_score), 0);
    m_iType = intent.getIntExtra(getString(R.string.score_parameter_type), Rally.GAME_A);
    m_sName = getString(R.string.score_default_name);

    //   
    LoadScore();

    // ? ??
    Arrays.sort(m_arrRecords);

    // ?  ??
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.score);

    // ?  
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    ((TextView) findViewById(R.id.custom_title_left_text)).setText(R.string.score_activity_title);
    ((TextView) findViewById(R.id.custom_title_right_text)).setText(R.string.application_upper);

    // ?  ? ? ??
    setListAdapter(new ScoreAdapter());

    //     ?  
    if ((0 < m_iScore) && (m_iScore > m_arrRecords[RECORDCOUNT - 1].m_iScore)) {
        showDialog(0);
    }
}