Example usage for android.content Intent getLongExtra

List of usage examples for android.content Intent getLongExtra

Introduction

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

Prototype

public long getLongExtra(String name, long defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.akop.crosswords.activity.CrosswordActivity.java

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

    setContentView(R.layout.activity_crossword);

    long crosswordId = CROSSWORD_ID_NONE;

    Intent intent = getIntent();
    if (intent != null) {
        crosswordId = intent.getLongExtra("crosswordId", CROSSWORD_ID_NONE);
    }//from   www  .  j  ava 2  s.  c  o  m

    WordReferenceMovementMethod rm = new WordReferenceMovementMethod();
    rm.setOnWordReferenceSelectedListener(new WordReferenceMovementMethod.OnWordReferenceSelectedListener() {
        @Override
        public void onWordReferenceSelected(int direction, int number) {
            if (mCrossword != null) {
                Crossword.Word word = mCrossword.findWord(direction, number);
                if (word != null) {
                    CharSequence hint = getHintText(word, mCrossword, false);
                    Toast.makeText(CrosswordActivity.this, hint, Toast.LENGTH_LONG).show();
                }
            }
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (savedInstanceState == null) {
        if (crosswordId == CROSSWORD_ID_NONE) {
            Crosswords.logv("Missing crossword id");
        } else {
            mCrossword = Storage.getInstance().getPuzzle(crosswordId);
        }

        if (mCrossword != null) {
            CrosswordFragment fragment = new CrosswordFragment();
            Bundle args = CrosswordFragment.createArgs(crosswordId, mCrossword);

            fragment.setArguments(args);
            FragmentManager fm = getSupportFragmentManager();
            fm.beginTransaction().add(R.id.container, fragment).commit();
        }
    } else {
        mCrossword = savedInstanceState.getParcelable("crossword");
    }

    if (mCrossword == null) {
        Crosswords.logv("No matching crossword found");
        finish();
        return;
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setCustomView(R.layout.template_crossword_actionbar_view);

    View customView = actionBar.getCustomView();
    mWordHint = (TextView) customView.findViewById(R.id.word_hint);
    mWordHint.setMovementMethod(rm);
}

From source file:org.messic.android.download.DownloadManagerService.java

public void onCreate() {
    super.onCreate();
    dm = (DownloadManager) getSystemService(Activity.DOWNLOAD_SERVICE);

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override/*from www.jav  a 2 s . c om*/
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                saveCover(pendingDownloads.get(downloadId));
                pendingDownloads.remove(downloadId);
                // Uri uri = dm.getUriForDownloadedFile( downloadId );
                // System.out.println( uri );
                // dm.remove( downloadId );
            }
        }
    };
    registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}

From source file:com.example.android.cloudnotes.ui.HomeActivity.java

private void viewNote(Intent launchIntent) {
    final long noteId = launchIntent.getLongExtra(EXTRA_NOTE_ID, -1);
    showNote(ContentUris.withAppendedId(NotesProvider.CONTENT_URI, noteId));
}

From source file:com.android.my.calendar.alerts.DismissAlarmsService.java

@Override
public void onHandleIntent(Intent intent) {
    if (AlertService.DEBUG) {
        Log.d(TAG, "onReceive: a=" + intent.getAction() + " " + intent.toString());
    }//from   ww w. j  av  a  2s  . c om

    long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1);
    long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1);
    long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1);
    long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY);
    long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY);
    int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1);
    List<AlarmId> alarmIds = new LinkedList<AlarmId>();

    Uri uri = CalendarAlerts.CONTENT_URI;
    String selection;

    // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms
    if (eventId != -1) {
        alarmIds.add(new AlarmId(eventId, eventStart));
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID
                + "=" + eventId;
    } else if (eventIds != null && eventIds.length > 0 && eventStarts != null
            && eventIds.length == eventStarts.length) {
        selection = buildMultipleEventsQuery(eventIds);
        for (int i = 0; i < eventIds.length; i++) {
            alarmIds.add(new AlarmId(eventIds[i], eventStarts[i]));
        }
    } else {
        // NOTE: I don't believe that this ever happens.
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED;
    }

    GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds);

    ContentResolver resolver = getContentResolver();
    ContentValues values = new ContentValues();
    values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED);
    resolver.update(uri, values, selection, null);

    // Remove from notification bar.
    if (notificationId != -1) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(notificationId);
    }

    if (SHOW_ACTION.equals(intent.getAction())) {
        // Show event on Calendar app by building an intent and task stack to start
        // EventInfoActivity with AllInOneActivity as the parent activity rooted to home.
        Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd);

        TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i)
                .startActivities();
    }
}

From source file:com.folkcat.run.activity.PhotoViewPagerActivity.java

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //???/*w ww.  j av  a 2s.c o  m*/
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //??
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    setContentView(R.layout.activity_photo_pager);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    toolbar.setNavigationIcon(getResources().getDrawable(R.mipmap.ic_close));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(false);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    if (savedInstanceState == null) {
        Intent i = getIntent();
        mPosition = i.getIntExtra("position", 0);
        mRunningId = i.getLongExtra("runningId", 0);
    } else {
        mPosition = savedInstanceState.getInt("position", 0);
        mRunningId = savedInstanceState.getLong("runningId", 0);
    }

    mPhotoList = PhotoUtil.getPthotosByRunningIdAndUpdateUi(mRunningId);
    mViewPager.setAdapter(new SamplePagerAdapter());
    if (savedInstanceState != null) {
        boolean isLocked = savedInstanceState.getBoolean(ISLOCKED_ARG, false);
        ((HackyViewPager) mViewPager).setLocked(isLocked);
    }
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            mPosition = position;

        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    mViewPager.setCurrentItem(mPosition);

}

From source file:com.chocopepper.chococam.activity.friends.manage.FriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.friends);//  ww  w.j a v a  2  s.c  om

    sharedPref = getSharedPreferences(Constants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    selectedPagerIndex = sharedPref.getInt(PAGER_INDEX, VIEW_FRIENDLIST);

    ImageView btnCreatechat = (ImageView) findViewById(R.id.btnCreateChat);
    btnCreatechat.setVisibility(View.GONE);

    TextView txt_title = (TextView) findViewById(R.id.title);
    txt_title.setText(R.string.friends_tab_sub_suggestion);

    List<Fragment> fragments = new Vector<Fragment>();

    final Fragment frFreindsList = Fragment.instantiate(this, FriendsList.class.getName());

    Intent i = getIntent();
    long target_user_id = i.getLongExtra(Constants.TARGET_USER_ID,
            UserService.getDefaultUserId(FriendsActivity.this));
    Bundle args = new Bundle();
    args.putLong(Constants.TARGET_USER_ID, target_user_id);

    selectedPagerIndex = i.getIntExtra(PAGER_INDEX, selectedPagerIndex);

    frFreindsList.setArguments(args);
    fragments.add(frFreindsList);
    //fragments.add(Fragment.instantiate(this, FriendsList.class.getName()));

    fragments.add(Fragment.instantiate(this, RecommendedFriends.class.getName()));
    fragments.add(Fragment.instantiate(this, ReceivedRequests.class.getName()));

    btnEdit = (RelativeLayout) findViewById(R.id.btnEdit);
    btnEdit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // ? ? ?   ?
            ((FriendsList) frFreindsList).switchEditMode();
        }
    });

    mAdapter = new FriendsAdapter(getSupportFragmentManager(), fragments);
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_current_friends));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_suggestion));
    //mAdapter.addTitle(this.getString(R.string.friends_tab_sub_invitation));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_received_invitation));

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAdapter);

    //  .
    mViewPager.setCurrentItem(selectedPagerIndex);
    // 2012-05-23 brucewang
    if (selectedPagerIndex == 0) {
        btnEdit.setVisibility(View.VISIBLE);
    }

    //mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
    //        mIndicator = (ViewPagerIndicator)findViewById(R.id.indicator);
    //      mIndicator.addPageChangeListener(this);
    //        mViewPager.setOnPageChangeListener(mIndicator);

    indicator = (TitlePageIndicator) findViewById(R.id.indicator);
    indicator.setFooterIndicatorStyle(IndicatorStyle.None);
    indicator.setViewPager(mViewPager, selectedPagerIndex);
    indicator.setOnPageChangeListener(this);
    mViewPager.setOnPageChangeListener(indicator);

}

From source file:com.stfalcon.socialauthhelper.twitter.TwitterClient.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == TWITTER_AUTH_CODE) {
            this.accessToken = data.getStringExtra(TwitterAuthActivity.KEY_ACCESS_TOKEN);
            this.userId = data.getLongExtra(TwitterAuthActivity.KEY_USER_ID, 0);
            this.userName = data.getStringExtra(TwitterAuthActivity.KEY_USER_NAME);
            this.sessionId = data.getLongExtra(TwitterAuthActivity.KEY_SESSION_ID, 0);
            authListener.onAuthorized();
        }/*from   w  ww .j a v a  2  s  .  c  o m*/
    }
}

From source file:org.droid2droid.install.AskAcceptDownloadApkActivity.java

@Override
public Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_IMPORT:
        Intent intent = getIntent();
        String deviceName = intent.getStringExtra(EXTRA_DEVICE);
        String description = intent.getStringExtra(EXTRA_DESCRIPTION);
        long totalBytes = intent.getLongExtra(EXTRA_SIZE, 0);
        ConnectionType type = ConnectionType.valueOf(intent.getStringExtra(EXTRA_CHANEL));
        String text;/*from  w w w  .  j  ava 2  s. c o  m*/
        if (type != ConnectionType.GSM) {
            text = getString(R.string.ask_download_apk_describe_wifi, deviceName, description,
                    Formatter.formatFileSize(this, totalBytes));
        } else {
            text = getString(R.string.ask_download_apk_describe, deviceName, description,
                    Formatter.formatFileSize(this, totalBytes));
        }

        return new AlertDialog.Builder(this).setTitle(R.string.ask_download_apk_title).setMessage(text)
                .setPositiveButton(R.string.ask_download_apk_accept, this)
                .setNegativeButton(R.string.ask_download_apk_decline, this).create();
    default:
        return null;
    }
}

From source file:com.nogago.android.tracks.widgets.TrackWidgetProvider.java

@Override
public void onReceive(Context aContext, Intent intent) {
    super.onReceive(aContext, intent);
    initialize(aContext);/*  www .  j a  v a  2 s  . c  o  m*/

    selectedTrackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra),
            selectedTrackId);
    String action = intent.getAction();

    if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)
            || AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)
            || trackStartedBroadcastAction.equals(action) || trackStoppedBroadcastAction.equals(action)) {
        updateTrack(action);
    }
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.media.MediaManagerService.java

private long getTargetId(@NonNull final Intent intent) {
    if (!intent.hasExtra(EXTRA_TARGET_ID)) {
        throw new IllegalArgumentException("EXTRA_TARGET_ID is not passed");
    }//ww  w  . jav  a 2 s.c  o  m

    return intent.getLongExtra(EXTRA_TARGET_ID, 0L);
}