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:ru.kaefik.isaifutdinov.an_weather_widget.city.CityModel.java

public void getExtraIntent(Intent intent) throws ParseException {
    setName(intent.getStringExtra("name"));
    setId(intent.getLongExtra("id", 0));
    setCountry(intent.getStringExtra("country"));
    setTemp(intent.getFloatExtra("temp", 0.0f));
    setClouds(intent.getFloatExtra("clouds", 0.0f));
    setPressure(intent.getFloatExtra("pressure", 0.0f));
    setHuminidity(intent.getFloatExtra("huminidity", 0.0f));
    setWindspeed(intent.getFloatExtra("windspeed", 0.0f));
    setWinddirection(intent.getFloatExtra("winddirection", 0.0f));
    setTimeRefresh(intent.getStringExtra("timeRefresh"));
    //     mWeather
    setWeather("mId", intent.getStringExtra("weather-id"));
    setWeather("icon", intent.getStringExtra("weather-icon"));
    setWeather("description", intent.getStringExtra("weather-description"));
    setWeather("temp", intent.getStringExtra("weather-temp"));
    setMYAPPID(intent.getStringExtra("appid"));
}

From source file:org.strongswan.android.ui.fragment.VpnProfileListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case ADD_REQUEST:
    case EDIT_REQUEST:
        if (resultCode == Activity.RESULT_OK) {
            //?????KEY_ID
            long id = data.getLongExtra(VpnProfileDataSource.KEY_ID, 0);
            //???VpnProfile
            VpnProfile profile = mDataSource.getVpnProfile(id);
            //???
            if (profile != null) {
                /* in case this was an edit, we remove it first */
                mVpnProfiles.remove(profile);
                mVpnProfiles.add(profile);
                mListAdapter.notifyDataSetChanged();
            }//  w  w w.j av a  2 s . co  m
            return;
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:ca.ddaly.android.heart.Heart.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REC_REQUEST && resultCode == SherlockFragmentActivity.RESULT_OK) {
        if (BuildConfig.DEBUG) {
            Log.v(TAG, "got activity result: " + data.getExtras().get("ca.ddaly.android.heart.REC_ID"));
        }/*from  w  ww .  j a  va2s  .  co m*/

        Long newRecID = data.getLongExtra("ca.ddaly.android.heart.REC_ID", 0);
        if (myList != null) {
            // list fragment exists
            // update the edit fragment
            switchNewEditFrag(newRecID);
        } else {
            // postpone the edit fragment switch until this activity has been restarted
            switchToRecID = newRecID;
        }
    }
}

From source file:net.sf.diningout.app.ui.RestaurantActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    mId = intent.getLongExtra(EXTRA_ID, 0L);
    int tab = intent.getIntExtra(EXTRA_TAB, 0);
    mActionBarSize = Themes.getActionBarSize(this);
    setContentView(R.layout.restaurant_activity);
    mPager.setOffscreenPageLimit(sTabTitles.length - 1); // keep all Fragments alive
    mPager.setAdapter(new PagerAdapter());
    mTabs.setViewPager(mPager);//from  ww w .j  a v  a 2  s  .  com
    mTabs.setOnPageChangeListener(new PageChangeListener());
    mTabs.setOnTouchListener(new TabsTouchListener());
    if (savedInstanceState == null && tab > 0) {
        mPager.setCurrentItem(tab);
    }
}

From source file:com.android.mms.quickmessage.QuickMessageWear.java

private void parseIntent(Intent i) {
    if (i == null) {
        return;// ww w  .  j av  a2  s .c o  m
    }
    //parse the remote input into a message that can be sent
    Bundle remoteInput = RemoteInput.getResultsFromIntent(i);
    CharSequence message = remoteInput.getCharSequence(EXTRA_VOICE_REPLY);
    String sender = i.getStringExtra(SMS_SENDER);
    String contactName = i.getStringExtra(SMS_CONATCT);
    long tId = i.getLongExtra(SMS_THEAD_ID, -1);
    //Only send if we have a valid thread id
    if (tId != -1) {
        String[] dest = new String[] { sender };

        SmsMessageSender smsMessageSender = new SmsMessageSender(getBaseContext(), dest, message.toString(),
                tId, SubscriptionManager.getDefaultSmsSubId());
        try {
            smsMessageSender.sendMessage(tId);
            Toast.makeText(mContext, getString(R.string.qm_wear_sending_message, contactName),
                    Toast.LENGTH_LONG).show();
        } catch (MmsException e) {
            Log.e(TAG, "Mms Exception thrown as follows: " + e);
            Toast.makeText(mContext, getString(R.string.qm_wear_messaged_failed, contactName),
                    Toast.LENGTH_LONG).show();
        }
    } else {
        Toast.makeText(mContext, getString(R.string.qm_wear_messaged_failed, contactName), Toast.LENGTH_LONG)
                .show();
    }
    //gotta mark as read even if it doesn't send since we read
    // the message and tried to respond to it
    Conversation con = Conversation.get(mContext, tId, true);
    if (con != null) {
        con.markAsRead(true);
        if (DEBUG)
            Log.d(TAG, "markAllMessagesRead(): Marked message " + tId + " as read");
    }
    finish();
}

From source file:org.schabi.terminightor.NightKillerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);

    if (intent != null) {
        Log.d(TAG, "get data from intent");
        try {/*w ww .  java  2  s  . c o m*/
            alarm = Alarm.getFromCursorItem(AlarmDBOpenHelper.getAlarmDBOpenHelper(this)
                    .getReadableItem(intent.getLongExtra(Alarm.ID, -1)));
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (!alarm.isRepeatEnabled()) {
            alarm.setEnabled(false);
            AlarmDBOpenHelper.getAlarmDBOpenHelper(this).update(alarm);
        }

        indicator.saveAlarm(alarm);
    } else {
        Log.d(TAG, "get data from indicator");
        try {
            alarm = indicator.restoreAlarm(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = { 1000, 200, 200, 200 };
    if (alarm.isVibrate()) {
        vibrator.vibrate(pattern, 0);
    }

    mediaPlayer = setupNewMediaPlayer(alarm);
    mediaPlayer.start();

    alarmActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
            | Intent.FLAG_FROM_BACKGROUND);
    alarmActivityIntent.putExtra(Alarm.ID, alarm.getId());
    alarmActivityIntent.putExtra(Alarm.NAME, alarm.getName());
    alarmActivityIntent.putExtra(Alarm.NFC_TAG_ID, alarm.getNfcTagId());
    this.startActivity(alarmActivityIntent);

    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification n = new NotificationCompat.Builder(this).setContentTitle(getString(R.string.alarm))
            .setContentText(alarm.getName()).setSmallIcon(R.drawable.terminightor_notify_small).setOngoing(true)
            .build();
    n.contentIntent = PendingIntent.getActivity(this.getApplicationContext(),
            SpecialPendingIds.OPEN_ALARM_ACTIVITY, alarmActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    nm.notify(NOTIFICATION_ID, n);

    return START_STICKY;
}

From source file:com.miljin.setminder.TimerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    //keep CPU on while timer is ticking
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    final PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
            "MyWakelockTag");
    wakeLock.acquire();//  www  . j av a  2 s  .c om

    seconds = intent.getLongExtra(MainActivity.EXTRA_START_TIME, 0);

    Intent getActivityIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, getActivityIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    //make notification
    notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder
            .setContentTitle(getResources().getString(com.miljin.setminder.R.string.notification_title));
    if (seconds >= 120) {
        notificationBuilder.setContentText(Long.toString(seconds / 60)
                + getResources().getString(com.miljin.setminder.R.string.notification_text_plural));
    } else {
        notificationBuilder.setContentText(
                getResources().getString(com.miljin.setminder.R.string.notification_text_minute));
    }
    notificationBuilder.setSmallIcon(com.miljin.setminder.R.drawable.ic_notification);
    notificationBuilder.setContentIntent(pendingIntent);
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(notifyID, notificationBuilder.build());

    myCountDownTimer = new CountDownTimer(seconds * 1000, 100) {
        public void onTick(long millisUntilFinished) {
            timerServiceTicking = true;
            broadcastTime(millisUntilFinished);
            sendNotification(millisUntilFinished);
        }

        public void onFinish() {
            timerServiceTicking = false;
            broadcastDone();
            wakeLock.release();
        }
    };
    myCountDownTimer.start();

    return START_NOT_STICKY;
}

From source file:com.ninetwozero.battlelog.fragments.ForumFragment.java

public void openForum(Intent data) {

    if (textTitle == null) {

        storedRequest = data;//  w  w w .  j  a  v  a2  s. c o m

    } else {

        forumId = data.getLongExtra("forumId", 0);
        textTitle.setText(data.getStringExtra("forumTitle"));
        loadFresh = true;
        reload();

    }

}

From source file:org.godotengine.godot.storage.Storage.java

public void init(FirebaseApp firebaseApp) {
    mFirebaseApp = firebaseApp;//from w  w  w.j ava 2 s  .c om

    // Local broadcast receiver
    mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Utils.d("SD:OnReceive:" + intent.toString());

            // hideProgressDialog(); // Hiding our progress dialog

            switch (intent.getAction()) {
            case DownloadService.DOWNLOAD_COMPLETED:
                // Get number of bytes downloaded
                long numBytes = intent.getLongExtra(DownloadService.EXTRA_BYTES_DOWNLOADED, 0);

                // Alert success
                // activity.getString(R.string.success),

                /**
                showMessageDialog("Success",
                String.format(Locale.getDefault(),
                "%d bytes downloaded from %s", numBytes,
                intent.getStringExtra(DownloadService.EXTRA_DOWNLOAD_PATH)));
                **/
                break;
            case DownloadService.DOWNLOAD_ERROR:
                // Alert failure
                /**
                showMessageDialog("Error",
                String.format(Locale.getDefault(), "Failed to download from %s",
                intent.getStringExtra(DownloadService.EXTRA_DOWNLOAD_PATH)));
                **/
                break;
            //            case MyUploadService.UPLOAD_COMPLETED:
            //            case MyUploadService.UPLOAD_ERROR:
            //               onUploadResultIntent(intent);
            //               break;
            }
        }
    };

    onStart();

    Utils.d("Initilaized Storage");
}

From source file:com.chatwork.android.realmcw.activities.RoomListActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == SEND_MESSAGE_REQUEST) {
        if (resultCode == RESULT_OK) {
            final long roomId = data.getLongExtra("ROOM_ID", 0);
            final String sendMessage = data.getStringExtra("SEND_MESSAGE");
            final String token = Utils.getSharedPreferences(getApplicationContext())
                    .getString(Utils.CW_API_TOKEN_PREFS_KEY, "");
            if (token != null) {
                ChatWorkClient.sendMessage(token, roomId, sendMessage);
            } else {
                Log.d(TAG, "ChatWork API Token is empty");
            }//w w w.j a  v a 2s  .  co  m
        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(getApplicationContext(), "Input message is empty", Toast.LENGTH_SHORT).show();
        }
    }
}