Example usage for android.content Intent CATEGORY_DEFAULT

List of usage examples for android.content Intent CATEGORY_DEFAULT

Introduction

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

Prototype

String CATEGORY_DEFAULT

To view the source code for android.content Intent CATEGORY_DEFAULT.

Click Source Link

Document

Set if the activity should be an option for the default action (center press) to perform on a piece of data.

Usage

From source file:jackpal.androidterm.RemoteInterface.java

private String switchToWindow(String handle, String iInitialCommand) {
    TermService service = mTermService;/*from   w  w w .j  a va2 s .  c om*/
    if (service == null) {
        finish();
        return null;
    }

    // Find the target window
    SessionList sessions = service.getSessions();
    ShellTermSession target = null;
    int index;
    for (index = 0; index < sessions.size(); ++index) {
        ShellTermSession session = (ShellTermSession) sessions.get(index);
        String h = session.getHandle();
        if (h != null && h.equals(handle)) {
            target = session;
            break;
        }
    }

    if (target == null) {
        if (sessions.isEmpty() || iInitialCommand == null)
            return openNewWindow(iInitialCommand);
        target = (ShellTermSession) sessions.get(0);
    }

    if (iInitialCommand != null) {
        target.write(iInitialCommand);
        target.write('\r');
    }

    handle = target.getHandle();
    Intent intent = new Intent(PRIVACT_SWITCH_WINDOW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(PRIVEXTRA_TARGET_WINDOW, index);
    startActivity(intent);
    return handle;
}

From source file:org.iota.wallet.ui.activity.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//ww  w  .  j a  v a  2  s .  c  o  m
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    switch (requestCode) {
    case Constants.REQUEST_CAMERA_PERMISSION:
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

            // permission was granted!

        } else {

            // permission denied!

            if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
                Snackbar.make(findViewById(R.id.drawer_layout), R.string.messages_permission_camera,
                        Snackbar.LENGTH_LONG).setAction(R.string.buttons_ok, view -> {
                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                                    Uri.parse("package:" + getPackageName()));
                            intent.addCategory(Intent.CATEGORY_DEFAULT);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivityForResult(intent, Constants.REQUEST_CAMERA_PERMISSION);
                        }).show();
            }
        }
    }
}

From source file:com.thingsee.tracker.MainActivity.java

@Override
public void onMapReady(GoogleMap map) {
    mMap = map;/*from   w  w  w  .jav  a  2 s  .  co m*/

    TileProvider wmsTileProvider = TileProviderFactory.getKapsiWmsTileProvider();
    mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider).fadeIn(true));

    initGoogleMap();

    trackerList = (HorizontalScrollView) this.findViewById(R.id.tracker_scroll_area);
    mTrackerItemLayout = (LinearLayout) findViewById(R.id.trackers);

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mainari, 16));
    Marker mark = mMap.addMarker(new MarkerOptions().position(mainari));

    ImageView locateButton = (ImageView) findViewById(R.id.app_icon);

    //set the ontouch listener
    locateButton.setOnTouchListener(new OnTouchListener() {

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                ImageView view = (ImageView) v;
                view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
                view.invalidate();
                break;
            }
            case MotionEvent.ACTION_UP:
                if (onChildOnMapView) {
                    onUpPressed();
                } else {
                    userZoomAndPanOnMap = false;
                    zoomToBoundingBox();
                }
            case MotionEvent.ACTION_CANCEL: {
                ImageView view = (ImageView) v;
                //clear the overlay
                view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect),
                        PorterDuff.Mode.SRC_ATOP);
                view.invalidate();
                break;
            }
            }

            return true;
        }
    });

    ImageView settingsButton = (ImageView) findViewById(R.id.header_settings_icon);

    //set the ontouch listener
    settingsButton.setOnTouchListener(new OnTouchListener() {

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                ImageView view = (ImageView) v;
                //overlay is black with transparency of 0x77 (119)
                view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
                view.invalidate();
                break;
            }
            case MotionEvent.ACTION_UP:
                final Dialog verificationQuery = new Dialog(mContext,
                        android.R.style.Theme_Translucent_NoTitleBar);
                verificationQuery.requestWindowFeature(Window.FEATURE_NO_TITLE);
                verificationQuery.setCancelable(false);
                verificationQuery.setContentView(R.layout.request_admin_code);
                ClearTextView ok = (ClearTextView) verificationQuery.findViewById(R.id.ok);
                ok.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        verificationQuery.dismiss();
                        EditText code = (EditText) verificationQuery.findViewById(R.id.verification_code);
                        if (code.getText().toString().equalsIgnoreCase("password")) {
                            Intent intent = new Intent(MainActivity.this, MenuActivity.class);
                            startActivity(intent);
                        }
                    }
                });
                ClearTextView cancel = (ClearTextView) verificationQuery.findViewById(R.id.cancel);
                cancel.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        verificationQuery.dismiss();
                    }
                });
                verificationQuery.show();
                verificationQuery.getWindow().setDimAmount(0.5f);
                verificationQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
            case MotionEvent.ACTION_CANCEL: {
                ImageView view = (ImageView) v;
                //clear the overlay
                view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect),
                        PorterDuff.Mode.SRC_ATOP);
                view.invalidate();
                break;
            }
            }

            return true;
        }
    });

    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng position) {
            if (onChildOnMapView) {
                if (trackerModelWithMarker != null) {
                    trackerModelWithMarker.getMarker().showInfoWindow();
                }
            }
        }
    });

    mMap.setOnMarkerClickListener(new OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(Marker marker) {
            if (trackersActive) {
                LatLng latlng = marker.getPosition();
                userZoomAndPanOnMap = false;
                if ((latlng.latitude == mainari.latitude) && (latlng.longitude == mainari.longitude)) {
                    if (onChildOnMapView) {
                        if (trackerModelWithMarker != null) {
                            trackerModelWithMarker.getMarker().showInfoWindow();
                        }
                    }
                } else {
                    if (!onChildOnMapView) {
                        trackerModelWithMarker = null;
                        // Zoom to marker tapped
                        zoomToMarker(latlng);
                        //Remove other markers
                        for (String key : trackers.keySet()) {
                            TrackerModel trackerModel = trackers.get(key);
                            if (trackerModel.getLatestLatLng() != null) {
                                if ((trackerModel.getLatestLatLng().latitude == latlng.latitude)
                                        && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) {
                                    focusOnChildOnMap(trackerModel.getSerialNumber());
                                    trackerModelWithMarker = trackerModel;
                                    trackerModelWithMarker.getMarker().showInfoWindow();
                                }
                            }
                        }
                    } else {
                        trackerModelWithMarker.getMarker().showInfoWindow();
                        for (String key : trackers.keySet()) {
                            TrackerModel trackerModel = trackers.get(key);
                            if (trackerModel.getLatestLatLng() != null) {
                                if ((trackerModel.getLatestLatLng().latitude == latlng.latitude)
                                        && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) {
                                    onBackPressed();
                                }
                            }
                        }
                    }
                }
            }
            return true;
        }
    });
    mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

        // Use default InfoWindow frame
        @Override
        public View getInfoWindow(Marker arg0) {
            return null;
        }

        // Defines the contents of the InfoWindow
        @Override
        public View getInfoContents(Marker arg0) {

            // Getting view from the layout file info_window_layout
            View v = null;

            for (String key : trackers.keySet()) {
                TrackerModel trackerModel = trackers.get(key);
                if (trackerModel.getLatestLatLng() != null) {
                    if ((trackerModel.getLatestLatLng().latitude == arg0.getPosition().latitude)
                            && (trackerModel.getLatestLatLng().longitude == arg0.getPosition().longitude)) {
                        v = getLayoutInflater().inflate(R.layout.info_window, null);
                        trackerModelWithMarker = trackerModel;
                        TextView trackerAccuracy = (TextView) v
                                .findViewById(R.id.tracker_marker_popup_accuracy);
                        if (trackerModelWithMarker.getAccuracy() != -1) {
                            trackerAccuracy
                                    .setText(String.format(mResources.getString(R.string.tracker_accuracy),
                                            trackerModelWithMarker.getAccuracy()));
                        } else {
                            trackerAccuracy.setText(
                                    String.format(mResources.getString(R.string.tracker_accuracy), 0.0f));
                        }
                        TextView trackerDistanceTs = (TextView) v
                                .findViewById(R.id.tracker_marker_popup_update_timestamp);
                        if (trackerModelWithMarker.getLastLocationUpdate() != 0) {
                            String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources,
                                    trackerModelWithMarker.getLastLocationUpdate());
                            trackerDistanceTs.setText(
                                    mResources.getString(R.string.tracker_timestamp) + " " + timeStampText);
                        } else {
                            trackerDistanceTs.setText(mResources.getString(R.string.tracker_timestamp) + " - ");
                        }
                        trackerInfoWindow = v;
                    }
                }
            }
            // Returning the view containing InfoWindow contents
            return v;
        }
    });
    IntentFilter statusIntentFilter = new IntentFilter(CommonConstants.BROADCAST_ACTION);
    statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    mFetchCloudDataStateReceiver = new FetchCloudDataStateReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(mFetchCloudDataStateReceiver, statusIntentFilter);

    mapLoaded = true;
    if (splashReady) {
        mSplashHandler.postDelayed(splashScreenOffFromDisplay, 0);
    }
}

From source file:com.waz.zclient.pages.main.profile.camera.CameraFragment.java

public void openGallery() {
    Intent i;/*from  w ww. java  2  s.  co m*/
    if (BuildConfig.IS_TEST_GALLERY_ALLOWED
            && TestingGalleryUtils.isCustomGalleryInstalled(getActivity().getPackageManager())) {
        i = new Intent("com.wire.testing.GET_PICTURE");
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.setType(INTENT_GALLERY_TYPE);
    } else {
        i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType(INTENT_GALLERY_TYPE);
    }
    getActivity().startActivityForResult(i, REQUEST_GALLERY_CODE);
    getActivity().overridePendingTransition(R.anim.camera_in, R.anim.camera_out);
}

From source file:com.trail.octo.UploadDocs.java

public boolean askGalleryPermission() {
    check = false;//from   w  ww. ja va 2 s. c  o  m
    // Here, thisActivity is the current activity
    if (ContextCompat.checkSelfPermission(UploadDocs.this,
            Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(UploadDocs.this,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {
            Log.e("Permission", "Explain here");
            Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!",
                    Toast.LENGTH_LONG).show();
            final Intent i = new Intent();
            i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            i.addCategory(Intent.CATEGORY_DEFAULT);
            i.setData(Uri.parse("package:" + UploadDocs.this.getPackageName()));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(i);
            // Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.
        } else {

            // No explanation needed, we can request the permission.
            Log.e("Permission", "Requesting");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
                    PERMISSION_REQUEST_READ_EXTERAL_STORAGE);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    } else {
        return true;
    }
    return check;
}

From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java

/**
 * Shares the given text by encoding it as a barcode, such that another user can
 * scan the text off the screen of the device.
 *
 * @param text the text string to encode as a barcode
 * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants.
 * @return the {@link android.app.AlertDialog} that was shown to the user prompting them to download the app
 *   if a prompt was needed, or null otherwise
 *//*w w  w. j ava  2  s  .com*/
public final AlertDialog shareText(CharSequence text, CharSequence type) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setAction(BS_PACKAGE + ".ENCODE");
    intent.putExtra("ENCODE_TYPE", type);
    intent.putExtra("ENCODE_DATA", text);
    String targetAppPackage = findTargetAppPackage(intent);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intent.setPackage(targetAppPackage);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intent);
    if (fragment == null) {
        activity.startActivity(intent);
    } else {
        fragment.startActivity(intent);
    }
    return null;
}

From source file:com.dm.wallpaper.board.activities.WallpaperBoardActivity.java

private void registerBroadcastReceiver() {
    IntentFilter filter = new IntentFilter(WallpaperBoardReceiver.PROCESS_RESPONSE);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    mReceiver = new WallpaperBoardReceiver();
    registerReceiver(mReceiver, filter);
}

From source file:com.nutomic.syncthingandroid.util.BarcodeIntentIntegrator.java

/**
 * Shares the given text by encoding it as a barcode, such that another user can
 * scan the text off the screen of the device.
 *
 * @param text the text string to encode as a barcode
 * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants.
 * @return the {@link AlertDialog} that was shown to the user prompting them to download the app
 *   if a prompt was needed, or null otherwise
 */// w ww  . j  a  va2  s  . c  o m
@TargetApi(11)
public final AlertDialog shareText(CharSequence text, CharSequence type) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setAction(BS_PACKAGE + ".ENCODE");
    intent.putExtra("ENCODE_TYPE", type);
    intent.putExtra("ENCODE_DATA", text);
    String targetAppPackage = findTargetAppPackage(intent);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intent.setPackage(targetAppPackage);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intent);
    if (fragment != null) {
        fragment.startActivity(intent);
    } else if (fragmentV4 != null) {
        fragmentV4.startActivity(intent);
    } else {
        activity.startActivity(intent);
    }
    return null;
}

From source file:org.universAAL.android.proxies.ServiceCalleeProxy.java

/**
 * This is an auxiliary method that invokes this proxy when a service
 * request matched in the R API server, and the ServiceCall was sent here
 * through GCM. We receive a ServiceCall not a BusMessage nor a
 * ServiceRequest. It sends the response back to the R API rather than
 * through the inner bus.// w  w  w  .j  av a  2 s.  c  o  m
 * 
 * @param scall
 *            The ServiceCall as received from R API through GCM.
 * @param origincall
 *            The original ServiceCall URI as specified by the server. It is
 *            not the same as scall.getURI() since that object is created
 *            here in the client.
 */
public void handleCallFromGCM(ServiceCall scall, String origincall) {
    Boolean needsOuts = (Boolean) scall.getNonSemanticInput(AppConstants.UAAL_META_PROP_NEEDSOUTPUTS);
    Context ctxt = contextRef.get();
    if (ctxt != null) {
        // Prepare an intent for sending to Android grounded service
        Intent serv = new Intent(action);
        serv.addCategory(category);
        boolean expecting = false;
        // If a response is expected, prepare a callback receiver (which must be called by uaalized app)
        if ((replyAction != null && !replyAction.isEmpty())
                && (replyCategory != null && !replyCategory.isEmpty())) {
            // Tell the destination where to send the reply
            serv.putExtra(AppConstants.ACTION_META_REPLYTOACT, replyAction);
            serv.putExtra(AppConstants.ACTION_META_REPLYTOCAT, replyCategory);
            // Register the receiver for the reply
            receiver = new ServiceCalleeProxyReceiverGCM(origincall);
            IntentFilter filter = new IntentFilter(replyAction);
            filter.addCategory(replyCategory);
            ctxt.registerReceiver(receiver, filter);
            expecting = true;
        } else if (needsOuts != null && needsOuts.booleanValue()) {
            // No reply* fields set, but caller still needs a response, lets
            // build one (does not work for callers outside android MW)
            Random r = new Random();
            String action = AppConstants.ACTION_REPLY + r.nextInt();
            serv.putExtra(AppConstants.ACTION_META_REPLYTOACT, action);
            serv.putExtra(AppConstants.ACTION_META_REPLYTOCAT, Intent.CATEGORY_DEFAULT);
            // Register the receiver for the reply
            receiver = new ServiceCalleeProxyReceiverGCM(origincall);
            IntentFilter filter = new IntentFilter(action);
            filter.addCategory(Intent.CATEGORY_DEFAULT);
            ctxt.registerReceiver(receiver, filter);
            expecting = true;
        }
        // Take the inputs from the call and put them in the intent
        if (inputURItoExtraKEY != null && !inputURItoExtraKEY.isEmpty()) {
            VariableSubstitution.putCallInputsAsIntentExtras(scall, serv, inputURItoExtraKEY);
        }
        // Flag to avoid feeding back the intent to bus when intent is the same in app and in callerproxy 
        serv.putExtra(AppConstants.ACTION_META_FROMPROXY, true);
        // Send the intent to Android grounded service
        ComponentName started = null;
        try {
            // HACK: In android 5.0 it is forbidden to send implicit service intents like this one 
            started = ctxt.startService(serv);
        } catch (Exception e) {
            // Therefore if it fails, fail silently and try again with broadcast receivers
            started = null;
        }
        if (started == null) {
            // No android service was there, try with broadcast. Before, here it used to send failure response
            ctxt.sendBroadcast(serv); // No way to know if received. If no response, bus will timeout (?)
        } else if (!expecting) {
            // There is no receiver waiting a response, send success now
            ServiceResponse resp = new ServiceResponse(CallStatus.succeeded);
            sendResponseGCM(resp, origincall);
        }
        //TODO Handle timeout
    }
}

From source file:com.google.zxing.integration.android.SupportIntentIntegrator.java

/**
 * Shares the given text by encoding it as a barcode, such that another user can
 * scan the text off the screen of the device.
 *
 * @param text the text string to encode as a barcode
 * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants.
 * @return the {@link AlertDialog} that was shown to the user prompting them to download the app
 *   if a prompt was needed, or null otherwise
 *//*from ww  w.  j av a 2 s  . c  o  m*/
public final AlertDialog shareText(CharSequence text, CharSequence type) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setAction(BS_PACKAGE + ".ENCODE");
    intent.putExtra("ENCODE_TYPE", type);
    intent.putExtra("ENCODE_DATA", text);
    String targetAppPackage = findTargetAppPackage(intent);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intent.setPackage(targetAppPackage);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intent);
    if (fragment != null) {
        fragment.startActivity(intent);
    } else if (fragmentV4 != null) {
        fragmentV4.startActivity(intent);
    } else {
        activity.startActivity(intent);
    }
    return null;
}