Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:com.sixwonders.courtkiosk.CheckInActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 888) {
        if (resultCode == Pdf417ScanActivity.RESULT_OK && data != null) {
            // perform processing of the data here

            // for example, obtain parcelable recognition result
            Bundle extras = data.getExtras();
            Parcelable[] resultArray = data
                    .getParcelableArrayExtra(Pdf417ScanActivity.EXTRAS_RECOGNITION_RESULT_LIST);
            // Each element in resultArray inherits BaseRecognitionResult class and
            // represents the scan result of one of activated recognizers that have
            // been set up. More information about this can be found in
            // "Recognition settings and results" chapter
            ConnectionUtil connectionUtil = new ConnectionUtil();
            connectionUtil.authCall("Todd", "Lewis", "05/21/1953", (AsyncResponse) activity);
        }/* w w w.j a  v  a2 s . c  om*/
    }
}

From source file:com.thanu.schoolbustracker.RouteActivity.java

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

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    name = bundle.getString("uname");

    FragmentManager myFragmentManager = getFragmentManager();
    MapFragment myMapFragment = (MapFragment) myFragmentManager.findFragmentById(R.id.map);
    modifyRoute = (Button) findViewById(R.id.btnModifyRoute);

    myMap = myMapFragment.getMap();//from ww w .  j a v a2 s.  co m

    if (myMap != null) {

        myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        myMap.getUiSettings().setCompassEnabled(false);
        myMap.getUiSettings().setRotateGesturesEnabled(true);
        myMap.getUiSettings().setScrollGesturesEnabled(true);
        myMap.getUiSettings().setZoomControlsEnabled(true);
        myMap.getUiSettings().setZoomGesturesEnabled(true);
        LatLng location = new LatLng(6.796923, 79.922433);
        CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(6.796923, 79.922433));
        myMap.moveCamera(center);
        CameraPosition cameraPosition = new CameraPosition.Builder().target(location) // Sets the center of the map to Mountain
                // View
                .zoom(10) // Sets the zoom
                .bearing((float) 112.5) // Sets the orientation of the
                // camera to east
                .tilt(30) // Sets the tilt of the camera to 30 degrees
                .build(); // Creates a CameraPosition from the builder
        myMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

        // Opening the sharedPreferences object
        sharedPreferences = getSharedPreferences("location", 0);

        // Getting number of locations already stored
        locationCount = sharedPreferences.getInt("locationCount", 0);

        // Getting stored zoom level if exists else return 0
        String zoom = sharedPreferences.getString("zoom", "0");

        // If locations are already saved
        if (locationCount != 0) {

            String lat = "";
            String lng = "";

            // Iterating through all the locations stored
            for (int i = 0; i < locationCount; i++) {

                // Getting the latitude of the i-th location
                lat = sharedPreferences.getString("lat" + i, "0");

                // Getting the longitude of the i-th location
                lng = sharedPreferences.getString("lng" + i, "0");

                // Drawing marker on the map
                drawMarker(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)));
            }

            // Moving CameraPosition to last clicked position
            myMap.moveCamera(CameraUpdateFactory
                    .newLatLng(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng))));

            // Setting the zoom level in the map on last position is clicked
            myMap.animateCamera(CameraUpdateFactory.zoomTo(Float.parseFloat(zoom)));
        }

        modifyRoute.setOnClickListener(this);
        myMap.setOnMapClickListener(this);
        myMap.setOnMapLongClickListener(this);
        myMap.setOnMarkerClickListener(this);
    }

    markerClicked = false;

    if (name.equalsIgnoreCase("Admin")) {
        modifyRoute.setEnabled(true);
    }
}

From source file:com.esminis.server.library.service.server.installpackage.InstallerPackage.java

private void stopServer(Context context, ServerControl serverControl) {
    final CyclicBarrier barrier = new CyclicBarrier(2);
    final BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override/*from   w  w w  .j  a va 2  s .  c  o  m*/
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction() == null
                    || !intent.getAction().equals(MainActivity.getIntentActionServerStatus(context))) {
                return;
            }
            final Bundle extras = intent.getExtras();
            if (extras == null || extras.containsKey("errorLine") || extras.getBoolean("running")) {
                return;
            }
            try {
                barrier.await();
            } catch (InterruptedException | BrokenBarrierException ignored) {
            }
        }
    };
    context.registerReceiver(receiver, new IntentFilter(MainActivity.getIntentActionServerStatus(context)));
    preferences.set(context, Preferences.SERVER_STARTED, false);
    serverControl.requestStop(null);
    try {
        barrier.await();
    } catch (InterruptedException | BrokenBarrierException ignored) {
    }
    context.unregisterReceiver(receiver);
}

From source file:com.blueserial.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ActivityHelper.initialize(this);

    Intent intent = getIntent();
    Bundle b = intent.getExtras();
    mDevice = b.getParcelable(Homescreen.DEVICE_EXTRA);
    mDeviceUUID = UUID.fromString(b.getString(Homescreen.DEVICE_UUID));
    mMaxChars = b.getInt(Homescreen.BUFFER_SIZE);

    jsonParser = new JSONParser();
    url = "http://172.16.152.129/my_projects/android_database/add_sonar_data.php";

    Log.d(TAG, "Ready");

    mBtnDisconnect = (Button) findViewById(R.id.btnDisconnect);
    mBtnSend = (Button) findViewById(R.id.btnSend);
    mBtnClear = (Button) findViewById(R.id.btnClear);
    mTxtReceive = (TextView) findViewById(R.id.txtReceive);
    mEditSend = (EditText) findViewById(R.id.editSend);
    scrollView = (ScrollView) findViewById(R.id.viewScroll);
    chkScroll = (CheckBox) findViewById(R.id.chkScroll);
    chkReceiveText = (CheckBox) findViewById(R.id.chkReceiveText);
    mBtnClearInput = (Button) findViewById(R.id.btnClearInput);

    mTxtReceive.setMovementMethod(new ScrollingMovementMethod());

    mBtnDisconnect.setOnClickListener(new OnClickListener() {

        @Override//w ww .  ja  va2  s . c o  m
        public void onClick(View v) {
            mIsUserInitiatedDisconnect = true;
            new DisConnectBT().execute();
        }
    });

    mBtnSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            try {
                mBTSocket.getOutputStream().write(mEditSend.getText().toString().getBytes());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    mBtnClear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mEditSend.setText("");
        }
    });

    mBtnClearInput.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mTxtReceive.setText("");
        }
    });

}

From source file:com.wenwen.chatuidemo.activity.ContactlistFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    // ? ?//from ww w. jav  a  2s .com
    case Constants.ActionCode.ACT_FIND:
        if (data != null) {
            MyUser myUser = (MyUser) data.getExtras().get("myuser");
            contactList.add(myUser);
            adapter.notifyDataSetChanged();
        }
        break;
    }
}

From source file:io.github.carlorodriguez.alarmon.AlarmClockService.java

private void handleStart(Intent intent) {
    if (intent != null && intent.hasExtra(COMMAND_EXTRA)) {
        Bundle extras = intent.getExtras();
        int command = extras.getInt(COMMAND_EXTRA, COMMAND_UNKNOWN);

        final Handler handler = new Handler();
        final Runnable maybeShutdown = new Runnable() {
            @Override//  w w w .  ja  v  a  2  s.c  o m
            public void run() {
                if (pendingAlarms.size() == 0) {
                    stopSelf();
                }
            }
        };

        switch (command) {
        case COMMAND_NOTIFICATION_REFRESH:
            refreshNotification();
            handler.post(maybeShutdown);
            break;
        case COMMAND_DEVICE_BOOT:
            fixPersistentSettings();
            handler.post(maybeShutdown);
            break;
        case COMMAND_TIMEZONE_CHANGE:
            if (AppSettings.isDebugMode(getApplicationContext())) {
                Toast.makeText(getApplicationContext(), "TIMEZONE CHANGE, RESCHEDULING...", Toast.LENGTH_SHORT)
                        .show();
            }
            for (long alarmId : pendingAlarms.pendingAlarms()) {
                scheduleAlarm(alarmId);
                if (AppSettings.isDebugMode(getApplicationContext())) {
                    Toast.makeText(getApplicationContext(), "ALARM " + alarmId, Toast.LENGTH_SHORT).show();
                }
            }
            handler.post(maybeShutdown);
            break;
        default:
            throw new IllegalArgumentException("Unknown service command.");
        }
    }
}

From source file:io.ionic.links.IonicDeeplink.java

public void handleIntent(Intent intent) {
    final String intentString = intent.getDataString();

    // read intent
    String action = intent.getAction();
    Uri url = intent.getData();// ww  w .  ja  v  a2s . c  o m
    JSONObject bundleData = this._bundleToJson(intent.getExtras());
    Log.d(TAG, "Got a new intent: " + intentString + " " + intent.getScheme() + " " + action + " " + url);

    // if app was not launched by the url - ignore
    if (!Intent.ACTION_VIEW.equals(action) || url == null) {
        return;
    }

    // store message and try to consume it
    try {
        lastEvent = new JSONObject();
        lastEvent.put("url", url.toString());
        lastEvent.put("path", url.getPath());
        lastEvent.put("queryString", url.getQuery());
        lastEvent.put("scheme", url.getScheme());
        lastEvent.put("host", url.getHost());
        lastEvent.put("fragment", url.getFragment());
        lastEvent.put("extra", bundleData);
        consumeEvents();
    } catch (JSONException ex) {
        Log.e(TAG, "Unable to process URL scheme deeplink", ex);
    }
}

From source file:com.amazon.cordova.plugin.ADMMessageHandler.java

/** {@inheritDoc} */
@Override//from w ww .j  av a 2  s  . c o  m
protected void onMessage(final Intent intent) {
    // Extract the message content from the set of extras attached to
    // the com.amazon.device.messaging.intent.RECEIVE intent.

    // Extract the payload from the message
    Bundle extras = intent.getExtras();
    if (extras != null && (extras.getString(PushPlugin.MESSAGE) != null)) {
        // if we are in the foreground, just surface the payload, else post
        // it to the statusbar
        if (PushPlugin.isInForeground()) {
            extras.putBoolean(PushPlugin.FOREGROUND, true);
            PushPlugin.sendExtras(extras);
        } else {
            extras.putBoolean(PushPlugin.FOREGROUND, false);
            createNotification(this, extras);
        }
    }
}

From source file:eu.andlabs.studiolounge.gcp.GCPService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    log("on startCommand id=" + startId + "  flags=" + flags);
    mApp = (Messenger) intent.getParcelableExtra("messenger");
    packagename = intent.getExtras().getString("packageName");
    mName = intent.getExtras().getString("name");
    if (mSocketIO.isConnected() && loggedIn)
        mSocketIO.emit("state");
    else/*  w w w  .j  a  v a  2  s.c o m*/
        connect();
    return START_NOT_STICKY;
}

From source file:com.khoahuy.phototag.HomeActivity.java

private void handleSmallCameraPhoto(Intent intent) {

    if (mCurrentPhotoPath != null) {
        Bundle extras = intent.getExtras();
        Bitmap bm = (Bitmap) extras.get("data");
        File file = new File(mCurrentPhotoPath);
        if (file.exists())
            file.delete();/*w w w.j  av a2 s  . co m*/
        try {
            FileOutputStream out = new FileOutputStream(file);
            bm.compress(Bitmap.CompressFormat.JPEG, 90, out);
            out.flush();
            out.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        NFCItem item = new NFCItem();
        item.setNfcid(nfcid);
        item.setImage(mCurrentPhotoPath);
        item.setCheckIn(DateUtils.getCurrentTimestamp());
        nfcProvider.addWaitingItem(item);
        mCurrentPhotoPath = null;
    }

}