Example usage for android.app Activity RESULT_CANCELED

List of usage examples for android.app Activity RESULT_CANCELED

Introduction

In this page you can find the example usage for android.app Activity RESULT_CANCELED.

Prototype

int RESULT_CANCELED

To view the source code for android.app Activity RESULT_CANCELED.

Click Source Link

Document

Standard activity result: operation canceled.

Usage

From source file:edu.berkeley.cellscope.cscore.DeviceListActivity.java

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

    // Setup the window
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.device_list);

    // Set result CANCELED in case the user backs out
    setResult(Activity.RESULT_CANCELED);

    // Initialize the button to perform device discovery
    Button scanButton = (Button) findViewById(R.id.button_scan);
    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            doDiscovery();//w  ww .  j  av  a  2s .  c o  m
            v.setVisibility(View.GONE);
        }
    });

    // Initialize array adapters. One for already paired devices and
    // one for newly discovered devices
    mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
    mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);

    // Find and set up the ListView for paired devices
    ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
    pairedListView.setAdapter(mPairedDevicesArrayAdapter);
    pairedListView.setOnItemClickListener(mDeviceClickListener);

    // Find and set up the ListView for newly discovered devices
    ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
    newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
    newDevicesListView.setOnItemClickListener(mDeviceClickListener);

    // Register for broadcasts when a device is discovered
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    this.registerReceiver(mReceiver, filter);

    // Register for broadcasts when discovery has finished
    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    this.registerReceiver(mReceiver, filter);

    // Get the local Bluetooth adapter
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();

    // Get a set of currently paired devices
    Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();

    // If there are paired devices, add each one to the ArrayAdapter
    if (pairedDevices.size() > 0) {
        findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
        for (BluetoothDevice device : pairedDevices) {
            mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
        }
    } else {
        String noDevices = getResources().getText(R.string.none_paired).toString();
        mPairedDevicesArrayAdapter.add(noDevices);
    }
}

From source file:org.liberty.android.fantastischmemo.downloader.dropbox.DropboxDBListActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_CANCELED) {
        return;//  w w  w. j  a  v  a2 s  .c  o m
    }

    switch (requestCode) {
    case UPLOAD_ACTIVITY: {
        restartActivity();
        break;
    }
    }
}

From source file:com.dynamixsoftware.printingsample.ShareIntentFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_LICENSE) {
        switch (resultCode) {
        case RESULT_ACTIVATION_SUCCESS:
            showDialog(R.string.success, R.string.message_success_license_activation);
            break;
        case RESULT_ACTIVATION_ERROR:
            showDialog(R.string.error, R.string.message_error_license_activation);
            break;
        }/*w w w. j  ava 2  s .  c  om*/
    }
    if (requestCode == REQUEST_CODE_IMAGE && resultCode == Activity.RESULT_CANCELED)
        showDialog(R.string.cancelled, R.string.message_share_image_cancelled);
}

From source file:com.spondbob.bluetooth.BluetoothActivity.java

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

    // Setup the window
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.device_list);

    // Set result CANCELED in case the user backs out
    setResult(Activity.RESULT_CANCELED);

    // Initialize array adapters. One for already paired devices and
    // one for newly discovered devices
    mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);

    // Find and set up the ListView for newly discovered devices
    newDevicesListView = (ListView) findViewById(R.id.new_devices);
    newDevicesListView.setAdapter(mNewDevicesArrayAdapter);

    // Register for broadcasts when a device is discovered
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    this.registerReceiver(mReceiver, filter);

    // Register for broadcasts when discovery has finished
    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    this.registerReceiver(mReceiver, filter);

    // Get the local Bluetooth adapter
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
}

From source file:org.jfedor.nxtremotecontrol.ChooseDeviceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.device_list);
    setResult(Activity.RESULT_CANCELED);
    Button scanButton = (Button) findViewById(R.id.button_scan);
    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            doDiscovery();/* w  ww .  j av  a  2  s.  c o  m*/
            v.setVisibility(View.GONE);

        }
    });

    mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
    mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);

    ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
    pairedListView.setAdapter(mPairedDevicesArrayAdapter);
    pairedListView.setOnItemClickListener(mDeviceClickListener);

    ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
    newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
    newDevicesListView.setOnItemClickListener(mDeviceClickListener);

    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    this.registerReceiver(mReceiver, filter);

    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    this.registerReceiver(mReceiver, filter);

    mBtAdapter = BluetoothAdapter.getDefaultAdapter();

    Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();

    boolean empty = true;

    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            if ((device.getBluetoothClass() != null)
                    && (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.TOY_ROBOT)) {
                mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
                empty = false;
            }
        }
    }
    if (!empty) {
        findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
        findViewById(R.id.no_devices).setVisibility(View.GONE);
    }

    if (checkPlayService()) {
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }
}

From source file:org.mifos.androidclient.main.LoginActivity.java

@Override
public void onBackPressed() {
    super.onBackPressed();
    setResult(Activity.RESULT_CANCELED);
    finish();
}

From source file:org.firebears.scouting2846.TeamDetailFragment.java

private void onTeamLoaded(Cursor c) {
    if (c == null) {
        Log.d(TAG, "team not found");
        Activity a = getActivity();//from w w w .  j  av a 2  s. c  o m
        if (a != null) {
            Intent intent = new Intent();
            intent.putExtra(TeamListActivity.ERROR_CODE, R.string.invalid_number);
            a.setResult(Activity.RESULT_CANCELED, intent);
            a.finish();
        }
        return;
    }
    Log.d(TAG, "team loaded");
    if (null == root_view)
        return;
    Toolbar bar = (Toolbar) getActivity().findViewById(R.id.detail_toolbar);
    if (bar != null) {
        int team_num = c.getInt(c.getColumnIndex(Team.COL_TEAM_NUMBER));
        String nick = c.getString(c.getColumnIndex(Team.COL_NICKNAME));
        bar.setTitle("" + team_num + ' ' + nick);
    }
    setViewText(R.id.locality, c, Team.COL_LOCALITY);
    setViewText(R.id.region, c, Team.COL_REGION);
    setViewText(R.id.country, c, Team.COL_COUNTRY);
    TextView tv = setViewText(R.id.team_website, c, Team.COL_WEBSITE);
    Linkify.addLinks(tv, Linkify.WEB_URLS);
    tv = (TextView) root_view.findViewById(R.id.team_rookie_year);
    String t = c.getString(c.getColumnIndex(Team.COL_ROOKIE_YEAR));
    if (t != null)
        tv.setText(getText(R.string.rookie_year) + " " + t);
    initScoutingSpinner();
    setViewText(R.id.team_motto, c, Team.COL_MOTTO);
}

From source file:org.apache.cordova.CordovaInterfaceImpl.java

@Override
public void setActivityResultCallback(CordovaPlugin plugin) {
    // Cancel any previously pending activity.
    if (activityResultCallback != null) {
        activityResultCallback.onActivityResult(activityResultRequestCode, Activity.RESULT_CANCELED, null);
    }//from   ww  w  .  ja v  a  2  s .c  o m
    activityResultCallback = plugin;
}

From source file:com.money.manager.ex.assetallocation.AssetClassEditActivity.java

@Override
public boolean onActionCancelClick() {
    setResult(Activity.RESULT_CANCELED);
    finish();

    return true;
}

From source file:org.benetech.secureapp.activities.BulletinToMbaFileExporter.java

protected void handleException(Exception e, int id, String msg) {
    setResult(Activity.RESULT_CANCELED);

    super.handleException(e, id, msg);
}