Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

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

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.google.android.apps.iosched.ui.tablet.SessionsVendorsMultiPaneActivity.java

private void routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();/*from w w w  .j a  v  a 2  s .  c  o  m*/
    if (uri == null) {
        return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load track details
        showFullUI(true);
        if (!updateSurfaceOnly) {
            // TODO: don't assume the URI will contain the track ID
            String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
            loadTrackList(TracksDropdownFragment.VIEW_TYPE_SESSIONS, selectedTrackId);
            onTrackSelected(selectedTrackId);
            if (mShowHideMasterLayout != null) {
                mShowHideMasterLayout.showMaster(true, ShowHideMasterLayout.FLAG_IMMEDIATE);
            }
        }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
        // Load a session list, hiding the tracks dropdown and the tabs
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSessionList(uri, null);
            if (mShowHideMasterLayout != null) {
                mShowHideMasterLayout.showMaster(true, ShowHideMasterLayout.FLAG_IMMEDIATE);
            }
        }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load session details
        if (intent.hasExtra(EXTRA_MASTER_URI)) {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
            showFullUI(false);
            if (!updateSurfaceOnly) {
                loadSessionList((Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
                        ScheduleContract.Sessions.getSessionId(uri));
                loadSessionDetail(uri);
            }
        } else {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
            showFullUI(true);
            if (!updateSurfaceOnly) {
                loadSessionDetail(uri);
                loadTrackInfoFromSessionUri(uri);
            }
        }

    } else if (ScheduleContract.Vendors.CONTENT_TYPE.equals(mimeType)) {
        // Load a vendor list
        mViewType = TracksDropdownFragment.VIEW_TYPE_VENDORS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadVendorList(uri, null);
            if (mShowHideMasterLayout != null) {
                mShowHideMasterLayout.showMaster(true, ShowHideMasterLayout.FLAG_IMMEDIATE);
            }
        }

    } else if (ScheduleContract.Vendors.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load vendor details
        mViewType = TracksDropdownFragment.VIEW_TYPE_VENDORS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            Uri masterUri = (Uri) intent.getParcelableExtra(EXTRA_MASTER_URI);
            if (masterUri == null) {
                masterUri = ScheduleContract.Vendors.CONTENT_URI;
            }
            loadVendorList(masterUri, ScheduleContract.Vendors.getVendorId(uri));
            loadVendorDetail(uri);
        }
    }

    updateDetailBackground();
}

From source file:com.csipsimple.service.SipService.java

/**
 * {@inheritDoc}/*from w  w  w.  j  a  v  a 2  s.c om*/
 */
@SuppressWarnings("deprecation")
@Override
public void onStart(Intent intent, int startId) {
    Log.d("caijun", "service onstart");
    android.util.Log.d("checkStart", "onStart");
    super.onStart(intent, startId);
    if (intent != null) {
        Parcelable p = intent.getParcelableExtra(SipManager.EXTRA_OUTGOING_ACTIVITY);
        if (p != null) {
            ComponentName outActivity = (ComponentName) p;
            registerForOutgoing(outActivity);
        }
    }

    // Check connectivity, else just finish itself
    if (!isConnectivityValid()) {
        notifyUserOfMessage(R.string.connection_not_valid);
        Log.d(THIS_FILE, "Harakiri... we are not needed since no way to use self");
        cleanStop();
        return;
    }

    // Autostart the stack - make sure started and that receivers are there
    // NOTE : the stack may also be autostarted cause of phoneConnectivityReceiver
    if (!loadStack()) {
        return;
    }

    //if(directConnect) {
    Log.d(THIS_FILE, "Direct sip start");
    getExecutor().execute(new StartRunnable());
    /*
    }else {
    Log.d(THIS_FILE, "Defered SIP start !!");
    NetworkInfo netInfo = (NetworkInfo) connectivityManager.getActiveNetworkInfo();
    if(netInfo != null) {
    String type = netInfo.getTypeName();
    NetworkInfo.State state = netInfo.getState();
    if(state == NetworkInfo.State.CONNECTED) {
       Log.d(THIS_FILE, ">> on changed connected");
       deviceStateReceiver.onChanged(type, true);
    }else if(state == NetworkInfo.State.DISCONNECTED) {
       Log.d(THIS_FILE, ">> on changed disconnected");
       deviceStateReceiver.onChanged(type, false);
    }
    }else {
    deviceStateReceiver.onChanged(null, false);
    Log.d(THIS_FILE, ">> on changed disconnected");
    }
    }
    */
}

From source file:com.android.contacts.ContactSaveService.java

private void renameGroup(Intent intent) {
    long groupId = intent.getLongExtra(EXTRA_GROUP_ID, -1);
    String label = intent.getStringExtra(EXTRA_GROUP_LABEL);

    if (groupId == -1) {
        Log.e(TAG, "Invalid arguments for renameGroup request");
        return;// w w w .j  av  a 2  s.c  o  m
    }

    ContentValues values = new ContentValues();
    values.put(Groups.TITLE, label);
    final Uri groupUri = ContentUris.withAppendedId(Groups.CONTENT_URI, groupId);
    getContentResolver().update(groupUri, values, null, null);

    Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT);
    callbackIntent.setData(groupUri);
    deliverCallback(callbackIntent);
}

From source file:com.csipsimple.service.SipService.java

private void registerServiceBroadcasts() {
    if (serviceReceiver == null) {
        IntentFilter intentfilter = new IntentFilter();
        intentfilter.addAction(SipManager.ACTION_DEFER_OUTGOING_UNREGISTER);
        intentfilter.addAction(SipManager.ACTION_OUTGOING_UNREGISTER);
        serviceReceiver = new BroadcastReceiver() {
            @Override//from ww w.j a  va2  s .  com
            public void onReceive(Context context, Intent intent) {
                Log.d("checkIntent", "intent:" + intent.getAction());
                String action = intent.getAction();
                if (action.equals(SipManager.ACTION_OUTGOING_UNREGISTER)) {
                    unregisterForOutgoing(
                            (ComponentName) intent.getParcelableExtra(SipManager.EXTRA_OUTGOING_ACTIVITY));
                } else if (action.equals(SipManager.ACTION_DEFER_OUTGOING_UNREGISTER)) {
                    deferUnregisterForOutgoing(
                            (ComponentName) intent.getParcelableExtra(SipManager.EXTRA_OUTGOING_ACTIVITY));
                }
            }

        };
        registerReceiver(serviceReceiver, intentfilter);
    }
}

From source file:com.hackensack.umc.activity.ProfileSelfieManualCropActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case Constant.FRAGMENT_CONST_REQUEST_IMAGE_CAPTURE:
        if (resultCode == RESULT_OK) {
            /*Intent intent = new Intent(ProfileSelfieActivity.this, ActivityCropImage.class);
            intent.setData(imageUri);/*from  w w w . j a v a 2s.  co  m*/
            startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY);*/

            //cropPictureIntent(imageUri);
            Intent intent = new Intent(ProfileSelfieManualCropActivity.this, ActivityCropImage.class);
            intent.setData(imageUri);

            // intent.putExtra(Constant.Cropp_InterFace,  saveCroppedImage);
            intent.putExtra(Constant.SELECTED_IMAGE_VIEW, selectedImageView);
            startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY);
        }
        break;
    default:
        if (resultCode == RESULT_OK) {
            try {
                if (data != null) {
                    if (selectedImageView == Constant.SELFIE) {
                        imageUri = data.getData();
                        /*CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgSelfie, ProfileSelfieActivity.this);
                        byte[] byteArray = getIntent().getByteArrayExtra(Constant.BITMAP_IMAGE);
                        Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
                        getImageUris(imageUri, 5,bmp,null);*/

                        Bitmap bitmapImage = data.getParcelableExtra(Constant.CROPPED_IMAGE);
                        //bitmapImage=data.getParcelableExtra(Constant.CROPPED_IMAGE);
                        //bitmapImage = CameraFunctionality.getBitmapFromFile(imageUri.toString(), ProfileSelfieManualCropActivity.this);
                        // String base64=CameraFunctionality.readBasee64File(data.getStringExtra(Constant.BASE64_FILE_PATH));                                 // String base64 = Base64Converter.createBase64StringFromBitmap(bitmapImage, ProfileSelfieManualCropActivity.this);
                        // String base64=Base64Converter.createBitmapFromFileImage(imageUri);
                        String base64 = Base64Converter.createBase64StringFromBitmap(bitmapImage,
                                ProfileSelfieManualCropActivity.this);
                        getImageUris(imageUri, selectedImageView, null, base64);
                        //CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgIcFront, getActivity());
                        //

                        CameraFunctionality.setBitMapToImageView(imageUri.toString(), bitmapImage, imgSelfie,
                                ProfileSelfieManualCropActivity.this);
                        //pathSelfie = imageUri;

                        /*   Bitmap bitmapImage = CameraFunctionality.unCompressedImage(data.getByteArrayExtra(Constant.BITMAP_IMAGE));
                                
                           pathSelfie=Base64Converter.createBase64StringFroImage(bitmapImage,ProfileSelfieActivity.this);*/

                        txtSefileSet.setText(R.string.done);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        break;
    }
}

From source file:com.fvd.nimbus.PaintActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    ContentResolver cr;//from w w  w.jav a2 s  . c om
    InputStream is;
    if (requestCode == TAKE_PHOTO) {
        showProgress(false);
        if (resultCode == -1) {
            try {
                if (data != null) {
                    if (data.hasExtra("data")) {
                        //Bitmap bm = ;
                        drawView.setVisibility(View.INVISIBLE);
                        drawView.recycle();
                        drawView.setBitmap((Bitmap) data.getParcelableExtra("data"), 0);
                        drawView.setVisibility(View.VISIBLE);

                    }
                } else {
                    if (outputFileUri != null) {
                        cr = getContentResolver();
                        try {
                            is = cr.openInputStream(outputFileUri);
                            Bitmap bmp = BitmapFactory.decodeStream(is);
                            if (bmp.getWidth() != -1 && bmp.getHeight() != -1) {
                                drawView.setVisibility(View.INVISIBLE);
                                drawView.recycle();
                                drawView.setBitmap(bmp, 0);
                                drawView.setVisibility(View.VISIBLE);
                            }
                        } catch (Exception e) {
                            appSettings.appendLog("paint:onCreate  " + e.getMessage());
                        }
                    }
                }
            } catch (Exception e) {
                appSettings.appendLog("main:onActivityResult: exception -  " + e.getMessage());
            }
        }
        ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0);
    } else if (requestCode == TAKE_PICTURE) {
        showProgress(false);
        if (resultCode == -1 && data != null) {
            boolean temp = false;
            try {
                Uri resultUri = data.getData();
                String drawString = resultUri.getPath();
                InputStream input = getContentResolver().openInputStream(resultUri);

                drawView.setVisibility(View.INVISIBLE);
                drawView.recycle();
                drawView.setBitmap(BitmapFactory.decodeStream(input), 0);
                //drawView.forceRedraw();
                drawView.setVisibility(View.VISIBLE);
            } catch (Exception e) {
                appSettings.appendLog("main:onActivityResult  " + e.getMessage());

            }
        }
        ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0);
    } else if (requestCode == SHOW_SETTINGS) {
        switch (resultCode) {
        case RESULT_FIRST_USER + 1:
            Intent i = new Intent(getApplicationContext(), PrefsActivity.class);
            startActivity(i);
            //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
            overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
            break;
        case RESULT_FIRST_USER + 2:
            if (appSettings.sessionId.length() == 0)
                showLogin();
            else {
                appSettings.sessionId = "";
                //serverHelper.getInstance().setSessionId(appSettings.sessionId);
                Editor e = prefs.edit();
                e.putString("userMail", userMail);
                e.putString("userPass", "");
                e.putString("sessionId", appSettings.sessionId);
                e.commit();
                showLogin();
            }
            break;
        case RESULT_FIRST_USER + 3:
            try {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("market://details?id=" + getApplicationInfo().packageName)));
            } catch (Exception e) {
            }
        case RESULT_FIRST_USER + 4:
            Uri uri = Uri.parse(
                    "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide");
            Intent it = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(it);
            //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
            overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
            break;
        case RESULT_FIRST_USER + 5:
            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this,
                    AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // no alert dialog shown
                            //alertDialogShown = null;
                            // canceled
                            setResult(RESULT_CANCELED);
                            // and finish
                            //finish();
                        }
                    });
            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.setTitle(getString(R.string.license_title));

            // and show
            //alertDialogShown = alertDialog;
            try {
                alertDialog.show();
            } catch (final java.lang.Exception e) {
                // nothing to do
            } catch (final java.lang.Error e) {
                // nothing to do
            }
            break;
        default:
            break;
        }
    }

    if (requestCode == 3) {
        if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) {
            userMail = data.getStringExtra("userMail");
            userPass = data.getStringExtra("userPass");
            if (resultCode == RESULT_OK)
                sendRequest("user:auth",
                        String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass));
            else
                serverHelper.getInstance().sendOldRequest("user_register", String.format(
                        "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}",
                        userMail, userPass), "");
        }
    } else if (requestCode == 11) {
        if (appSettings.sessionId != "") {
            sessionId = appSettings.sessionId;
            userPass = appSettings.userPass;
            sendShot();
        }
    } else if (requestCode == 4) {
        if (resultCode == RESULT_OK) {
            String id = data.getStringExtra("id").toString();
            serverHelper.getInstance().shareShot(id);
        }
    } else if (resultCode == RESULT_OK) {
        drawView.setColour(dColor);
        setPaletteColor(dColor);
        Uri resultUri = data.getData();
        String drawString = resultUri.getPath();
        String galleryString = getGalleryPath(resultUri);

        if (galleryString != null) {
            drawString = galleryString;
        }
        // else another file manager was used
        else {
            if (drawString.contains("//")) {
                drawString = drawString.substring(drawString.lastIndexOf("//"));
            }
        }

        // set the background to the selected picture
        if (drawString.length() > 0) {
            Drawable drawBackground = Drawable.createFromPath(drawString);
            drawView.setBackgroundDrawable(drawBackground);
        }

    }
}

From source file:edu.stanford.mobisocial.dungbeetle.NearbyActivity.java

private void findBluetooth() {
    if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
        Intent bt = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(bt, RESULT_BT_ENABLE);
        return;/*w w  w.ja va 2 s .c  o  m*/
    }

    // Create a BroadcastReceiver for ACTION_FOUND
    final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);

    final BroadcastReceiver receiver = new BroadcastReceiver() {
        public void onReceive(final Context context, final Intent intent) {
            String action = intent.getAction();
            // When discovery finds a device
            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                new Thread() {
                    public void run() {
                        BluetoothBeacon.OnDiscovered discovered = new BluetoothBeacon.OnDiscovered() {
                            @Override
                            public void onDiscovered(final byte[] data) {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            JSONObject obj = new JSONObject(new String(data));
                                            mNearbyList.add(
                                                    new NearbyItem(NearbyItem.Type.FEED, obj.getString("name"),
                                                            Uri.parse(obj.getString("dynuri")), null));
                                            mAdapter.notifyDataSetChanged();
                                        } catch (JSONException e) {
                                            Log.e(TAG, "Error getting group info over bluetooth", e);
                                        }
                                    }
                                });
                            }
                        };
                        // Get the BluetoothDevice object from the Intent
                        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                        BluetoothBeacon.discover(NearbyActivity.this, device, discovered);
                    };
                }.start();
            }
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
                unregisterReceiver(this);
            }
        }
    };

    registerReceiver(receiver, filter); // Don't forget to unregister during
                                        // onDestroy
    BluetoothAdapter.getDefaultAdapter().startDiscovery();
    Toast.makeText(this, "Scanning Bluetooth...", 500).show();
}

From source file:com.mario22gmail.license.nfc_project.NavigationDrawerActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Log.i(nfcDebugTag, "Tag detected ");
    Toast.makeText(this, "Card detectat", Toast.LENGTH_SHORT).show();

    isCardEmpty = true;// www. j av  a 2 s  .  co m
    try {
        libInstance.filterIntent(intent, mCallback);
        //                FragmentPinDialog fragment = new FragmentPinDialog();
        //                fragment.show(getSupportFragmentManager(), "Mario popup");
        if (isDesfire == false) {

            if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) {
                Toast.makeText(this, "NfcIntent", Toast.LENGTH_SHORT).show();

                Log.i(nfcDebugTag, "Tag detectat");

                Parcelable[] parcelables = intent.getParcelableArrayExtra(nfcAdapter.EXTRA_NDEF_MESSAGES);
                if (parcelables != null && parcelables.length > 0) {
                    readTextFromTag((NdefMessage) parcelables[0]);
                } else {
                    Toast.makeText(this, "No NDEF Message Found", Toast.LENGTH_SHORT).show();
                }
            } else {
                Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
                String mesaj = "ce mai faci";
                NdefMessage ndefMessage = createNdefMessage(mesaj);
                writeNdefMessage(tag, ndefMessage);
            }
        }

        if (isCardEmpty) {
            FragmentEmptyState Fragment = new FragmentEmptyState();
            ChangeFragment(Fragment);
            //            ChangeFragment(chooseOptions);
            //                FragmentPinDialog fragment = new FragmentPinDialog();
            //                fragment.show(getSupportFragmentManager(), "Mario popup");

        } else {
            Log.i(nfcDebugTag, "A ajuns pe else pana la fragment");

            int lengthStack = getSupportFragmentManager().getFragments().size();
            Fragment lastFragment = getSupportFragmentManager().getFragments().get(lengthStack - 1);
            boolean isDialogFragment = FragmentPinDialog.class.isInstance(lastFragment);
            if (!isDialogFragment) {
                FragmentPinDialog fragment = new FragmentPinDialog();
                fragment.show(getSupportFragmentManager(), "Mario popup");
            }
        }
    } catch (CloneDetectedException e) {
        Toast.makeText(this, "Error_with_warning", Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        Log.i(nfcDebugTag, "Exceptia este" + e.getMessage());
    } finally {
        isDesfire = false;
    }
    Log.i(nfcDebugTag, "Nfc intent a ajuns la sfarsit");
}

From source file:com.fvd.nimbus.PaintActivity.java

/** Called when the activity is first created. */
@Override//from  w  ww.  ja  v a 2 s. co  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
    overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    try {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    } catch (Exception e) {
        e.printStackTrace();
    }
    ctx = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    dWidth = prefs.getInt("dWidth", 2);
    fWidth = prefs.getInt("fWidth", 1);
    dColor = prefs.getInt(pColor, Color.RED);
    saveFormat = Integer.parseInt(prefs.getString("saveFormat", "1"));
    serverHelper.getInstance().setCallback(this, this);
    serverHelper.getInstance().setMode(saveFormat);
    setContentView(R.layout.screen_edit);
    drawer = (DrawerLayout) findViewById(R.id.root);
    findViewById(R.id.bDraw1).setOnClickListener(this);
    findViewById(R.id.bDraw2).setOnClickListener(this);
    findViewById(R.id.bDraw3).setOnClickListener(this);
    findViewById(R.id.bDraw4).setOnClickListener(this);
    findViewById(R.id.bDraw5).setOnClickListener(this);
    findViewById(R.id.bDraw6).setOnClickListener(this);
    findViewById(R.id.bDraw8).setOnClickListener(this);
    findViewById(R.id.bColor1).setOnClickListener(this);
    findViewById(R.id.bColor2).setOnClickListener(this);
    findViewById(R.id.bColor3).setOnClickListener(this);
    findViewById(R.id.bColor4).setOnClickListener(this);
    findViewById(R.id.bColor5).setOnClickListener(this);
    paletteButton = (CircleButton) findViewById(R.id.bToolColor);
    paletteButton.setOnClickListener(this);

    paletteButton_land = (CircleButton) findViewById(R.id.bToolColor_land);
    //paletteButton_land.setOnClickListener(this);

    ((SeekBar) findViewById(R.id.seekBarLine)).setProgress(dWidth * 10);
    ((SeekBar) findViewById(R.id.seekBarType)).setProgress(fWidth * 10);

    ((TextView) findViewById(R.id.tvTextType)).setText(String.format("%d", 40 + fWidth * 20));

    findViewById(R.id.bUndo).setOnClickListener(this);
    findViewById(R.id.btnBack).setOnClickListener(this);
    findViewById(R.id.bClearAll).setOnClickListener(this);
    findViewById(R.id.bTurnLeft).setOnClickListener(this);
    findViewById(R.id.bTurnRight).setOnClickListener(this);
    findViewById(R.id.bDone).setOnClickListener(this);
    findViewById(R.id.bApplyText).setOnClickListener(this);

    ((ImageButton) findViewById(R.id.bStroke)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            v.setSelected(!v.isSelected());
        }
    });

    lineWidthListener = new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            if (true || fromUser) {
                /*dWidth = (progress/10);
                 drawView.setWidth((dWidth+1)*5);*/
                dWidth = progress;
                drawView.setWidth(dWidth);
                Editor e = prefs.edit();
                e.putInt("dWidth", dWidth);
                e.commit();
            }

        }
    };

    ((SeekBar) findViewById(R.id.seekBarLine)).setOnSeekBarChangeListener(lineWidthListener);
    ((SeekBar) findViewById(R.id.ls_seekBarLine)).setOnSeekBarChangeListener(lineWidthListener);

    fontSizeListener = new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub

            if (fromUser) {
                fWidth = progress / 10;
                int c = 40 + fWidth * 20;
                drawView.setFontSize(c);
                Editor e = prefs.edit();
                e.putInt("fWidth", fWidth);
                e.commit();
                try {
                    ((TextView) findViewById(R.id.tvTextType)).setText(String.format("%d", c));
                    ((TextView) findViewById(R.id.ls_tvTextType)).setText(String.format("%d", c));
                } catch (Exception ex) {

                }

            }
        }
    };

    ((SeekBar) findViewById(R.id.seekBarType)).setOnSeekBarChangeListener(fontSizeListener);
    ((SeekBar) findViewById(R.id.ls_seekBarType)).setOnSeekBarChangeListener(fontSizeListener);

    drawView = (DrawView) findViewById(R.id.painter);
    drawView.setWidth((dWidth + 1) * 5);
    drawView.setFontSize(40 + fWidth * 20);

    setBarConfig(getResources().getConfiguration().orientation);

    findViewById(R.id.bEditPage).setOnClickListener(this);
    findViewById(R.id.bToolColor).setOnClickListener(this);
    findViewById(R.id.bErase).setOnClickListener(this);
    findViewById(R.id.bToolShape).setOnClickListener(this);
    findViewById(R.id.bToolText).setOnClickListener(this);
    findViewById(R.id.bToolCrop).setOnClickListener(this);
    findViewById(R.id.btnBack).setOnClickListener(this);
    findViewById(R.id.bDone).setOnClickListener(this);
    findViewById(R.id.btnShare).setOnClickListener(this);
    findViewById(R.id.bSave2SD).setOnClickListener(this);
    findViewById(R.id.bSave2Nimbus).setOnClickListener(this);

    userMail = prefs.getString("userMail", "");
    userPass = prefs.getString("userPass", "");
    sessionId = prefs.getString("sessionId", "");

    appSettings.sessionId = sessionId;
    appSettings.userMail = userMail;
    appSettings.userPass = userPass;

    storePath = "";
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    //storePath= intent.getPackage().getClass().toString();
    if ((Intent.ACTION_VIEW.equals(action) || Intent.ACTION_SEND.equals(action)
            || "com.onebit.nimbusnote.EDIT_PHOTO".equals(action)) && type != null) {
        if (type.startsWith("image/")) {
            Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (imageUri == null)
                imageUri = intent.getData();
            if (imageUri != null) {
                String url = Uri.decode(imageUri.toString());
                if (url.startsWith(CONTENT_PHOTOS_URI_PREFIX)) {
                    url = getPhotosPhotoLink(url);
                } //else url=Uri.decode(url);

                ContentResolver cr = getContentResolver();
                InputStream is;

                try {
                    is = cr.openInputStream(Uri.parse(url));
                    if ("com.onebit.nimbusnote.EDIT_PHOTO".equals(action))
                        storePath = " ";//getGalleryPath(Uri.parse(url));
                    Bitmap bmp = BitmapFactory.decodeStream(is);
                    if (bmp.getWidth() != -1 && bmp.getHeight() != -1)
                        drawView.setBitmap(bmp, 0);
                } catch (Exception e) {
                    appSettings.appendLog("paint:onCreate  " + e.getMessage());
                }
            }
        }
    } else {
        String act = getIntent().getExtras().getString("act");
        if ("photo".equals(act)) {
            getPhoto();
        } else if ("picture".equals(act)) {
            getPicture();
        } else {
            String filePath = getIntent().getExtras().getString("path");
            boolean isTemp = getIntent().getExtras().getBoolean("temp");
            domain = getIntent().getExtras().getString("domain");
            if (domain == null)
                domain = serverHelper.getDate();
            if (filePath.contains("://")) {
                Bitmap bmp = helper.LoadImageFromWeb(filePath);
                if (bmp != null) {
                    drawView.setBitmap(bmp, 0);
                }
            } else {
                File file = new File(filePath);
                if (file.exists()) {
                    try {
                        int orient = helper.getOrientationFromExif(filePath);
                        Bitmap bmp = helper.decodeSampledBitmap(filePath, 1000, 1000);
                        if (bmp != null) {
                            drawView.setBitmap(bmp, orient);
                        }
                    } catch (Exception e) {
                        appSettings.appendLog("paint.onCreate()  " + e.getMessage());
                    }
                    if (isTemp)
                        file.delete();
                }
            }
        }
    }

    drawView.setBackgroundColor(Color.WHITE);
    drawView.requestFocus();
    drawView.setColour(dColor);
    setPaletteColor(dColor);

    drawView.setSelChangeListener(new shapeSelectionListener() {

        @Override
        public void onSelectionChanged(int shSize, int fSize, int shColor) {
            setSelectedFoot(0);
            setLandToolSelected(R.id.bEditPage_land);
            //updateColorDialog(shSize!=-1?(shSize/5)-1:dWidth, fSize!=-1?(fSize-40)/20:fWidth, shColor!=0?colorToId(shColor):dColor);
            dColor = shColor;
            ccolor = shColor;
            int sw = shSize != -1 ? shSize : dWidth;
            canChange = false;
            ((SeekBar) findViewById(R.id.seekBarLine)).setProgress(sw);
            ((SeekBar) findViewById(R.id.ls_seekBarLine)).setProgress(sw);
            setPaletteColor(dColor);
            drawView.setColour(dColor);
            canChange = true;
        }

        @Override
        public void onTextChanged(String text, boolean stroke) {

            if (findViewById(R.id.text_field).getVisibility() != View.VISIBLE) {
                hideTools();

                findViewById(R.id.bStroke).setSelected(stroke);
                ((EditText) findViewById(R.id.etEditorText)).setText(text);
                findViewById(R.id.text_field).setVisibility(View.VISIBLE);
                findViewById(R.id.etEditorText).requestFocus();
                ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                        .showSoftInput(findViewById(R.id.etEditorText), 0);
                findViewById(R.id.bToolText).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        setSelectedFoot(2);

                    }
                }, 100);

            }
        }

    });

    setColorButtons(dColor);

    //mPlanetTitles = getResources().getStringArray(R.array.lmenu_paint);

    /*ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_paint)));
    listView.setOnItemClickListener(this);*/
}

From source file:it.feio.android.omninotes.ListFragment.java

@Override
public// Used to show a Crouton dialog after saved (or tried to) a note
void onActivityResult(int requestCode, final int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    switch (requestCode) {
    case REQUEST_CODE_CATEGORY:
        // Dialog retarded to give time to activity's views of being completely initialized
        // The dialog style is choosen depending on result code
        switch (resultCode) {
        case Activity.RESULT_OK:
            mainActivity.showMessage(R.string.category_saved, ONStyle.CONFIRM);
            EventBus.getDefault().post(new CategoriesUpdatedEvent());
            break;
        case Activity.RESULT_FIRST_USER:
            mainActivity.showMessage(R.string.category_deleted, ONStyle.ALERT);
            break;
        default://from   w  ww. ja v a 2s .  c  o m
            break;
        }

        break;

    case REQUEST_CODE_CATEGORY_NOTES:
        if (intent != null) {
            Category tag = intent.getParcelableExtra(Constants.INTENT_CATEGORY);
            categorizeNotesExecute(tag);
        }
        break;

    case REQUEST_CODE_ADD_ALARMS:
        list.clearChoices();
        selectedNotes.clear();
        finishActionMode();
        list.invalidateViews();
        break;

    default:
        break;
    }

}