Java Code Examples for android.content.Intent#putIntegerArrayListExtra()

The following examples show how to use android.content.Intent#putIntegerArrayListExtra() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>A service can handle negative delays</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues1() {

    l(this, "@Test startServiceWithNegativeValues1");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000012", -20);   // How much delay for the start ?
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 2
Source File: ContactsPickerActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
private void multiFinish ()
{
    if (mSelection.size() > 0) {
        ArrayList<String> users = new ArrayList<>();
        ArrayList<Integer> providers = new ArrayList<>();
        ArrayList<Integer> accounts = new ArrayList<>();

        for (int i = 0; i < mSelection.size(); i++) {
            SelectedContact contact = mSelection.valueAt(i);
                users.add(contact.username);
                providers.add(contact.provider);
                accounts.add(contact.account);
        }

        Intent data = new Intent();
        data.putStringArrayListExtra(EXTRA_RESULT_USERNAMES, users);
        data.putIntegerArrayListExtra(EXTRA_RESULT_PROVIDER, providers);
        data.putIntegerArrayListExtra(EXTRA_RESULT_ACCOUNT, accounts);
        setResult(RESULT_OK, data);
        finish();
    }
}
 
Example 3
Source File: InvalidationIntentProtocol.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Create an Intent that will start the invalidation listener service and
 * register for the object ids with the specified sources and names.
 * Sync-specific objects are filtered out of the request since Sync types
 * are registered using the other version of createRegisterIntent.
 */
public static Intent createRegisterIntent(
        Account account, int[] objectSources, String[] objectNames) {
    if (objectSources.length != objectNames.length) {
        throw new IllegalArgumentException(
                "objectSources and objectNames must have the same length");
    }

    // Add all non-Sync objects to new lists.
    ArrayList<Integer> sources = new ArrayList<Integer>();
    ArrayList<String> names = new ArrayList<String>();
    for (int i = 0; i < objectSources.length; i++) {
        if (objectSources[i] != Types.ObjectSource.CHROME_SYNC) {
            sources.add(objectSources[i]);
            names.add(objectNames[i]);
        }
    }

    Intent registerIntent = new Intent(ACTION_REGISTER);
    registerIntent.putIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES, sources);
    registerIntent.putStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES, names);
    registerIntent.putExtra(EXTRA_ACCOUNT, account);
    return registerIntent;
}
 
Example 4
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with too small coordinates</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithToSmallCoordinates() {

    l(this, "@Test startServiceWithToSmallCoordinates");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(Integer.MIN_VALUE); // x0
    points.add(Integer.MIN_VALUE); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 5
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with negative coordinates</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues4() {

    l(this, "@Test startServiceWithNegativeValues4");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(42); // y0
    points.add(1337); // x1
    points.add(-50); // y1
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 6
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle negative repeat</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues3() {

    l(this, "@Test startServiceWithNegativeValues3");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000021", -10);    // The number of repeat to do
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 7
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 *< i>A service can handle negative time gaps</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues2() {

    l(this, "@Test startServiceWithNegativeValues2");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000013", -2);    // The amount of time to wait between clicks
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 8
Source File: InvalidationIntentProtocol.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Create an Intent that will start the invalidation listener service and
 * register for the object ids with the specified sources and names.
 * Sync-specific objects are filtered out of the request since Sync types
 * are registered using the other version of createRegisterIntent.
 */
public static Intent createRegisterIntent(Account account, int[] objectSources,
        String[] objectNames) {
    Preconditions.checkArgument(objectSources.length == objectNames.length,
        "objectSources and objectNames must have the same length");

    // Add all non-Sync objects to new lists.
    ArrayList<Integer> sources = new ArrayList<Integer>();
    ArrayList<String> names = new ArrayList<String>();
    for (int i = 0; i < objectSources.length; i++) {
        if (objectSources[i] != Types.ObjectSource.Type.CHROME_SYNC.getNumber()) {
            sources.add(objectSources[i]);
            names.add(objectNames[i]);
        }
    }

    Intent registerIntent = new Intent(ACTION_REGISTER);
    registerIntent.putIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES, sources);
    registerIntent.putStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES, names);
    registerIntent.putExtra(EXTRA_ACCOUNT, account);
    return registerIntent;
}
 
Example 9
Source File: InvalidationIntentProtocol.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Create an Intent that will start the invalidation listener service and
 * register for the object ids with the specified sources and names.
 * Sync-specific objects are filtered out of the request since Sync types
 * are registered using the other version of createRegisterIntent.
 */
public static Intent createRegisterIntent(Account account, int[] objectSources,
        String[] objectNames) {
    Preconditions.checkArgument(objectSources.length == objectNames.length,
        "objectSources and objectNames must have the same length");

    // Add all non-Sync objects to new lists.
    ArrayList<Integer> sources = new ArrayList<Integer>();
    ArrayList<String> names = new ArrayList<String>();
    for (int i = 0; i < objectSources.length; i++) {
        if (objectSources[i] != Types.ObjectSource.Type.CHROME_SYNC.getNumber()) {
            sources.add(objectSources[i]);
            names.add(objectNames[i]);
        }
    }

    Intent registerIntent = new Intent(ACTION_REGISTER);
    registerIntent.putIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES, sources);
    registerIntent.putStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES, names);
    registerIntent.putExtra(EXTRA_ACCOUNT, account);
    return registerIntent;
}
 
Example 10
Source File: ChoiceDialog.java    From currency with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id)
{
    // Check mode
    switch (mode)
    {
    // Normal
    case Main.DISPLAY_MODE:
        selectList.add(position);
        // Return new currency in intent
        Intent intent = new Intent();
        intent.putIntegerArrayListExtra(Main.CHOICE,
                                        (ArrayList<Integer>) selectList);
        setResult(RESULT_OK, intent);
        finish();
        break;

    // Select
    case Main.SELECT_MODE:
        if (selectList.contains(position))
            selectList.remove(selectList.indexOf(position));

        else
            selectList.add(position);

        if (selectList.isEmpty())
        {
            if (clear != null)
                clear.setEnabled(false);
            if (select != null)
                select.setEnabled(false);
            mode = Main.DISPLAY_MODE;
        }

        adapter.notifyDataSetChanged();
        break;
    }
}
 
Example 11
Source File: SelectMultiPointsActivity.java    From SmoothClicker with MIT License 5 votes vote down vote up
/**
 * Triggered when the back button is pressed
 */
@Override
public void onBackPressed(){
    cleanHelpingToastsRoutine();
    Intent returnIntent = new Intent();
    returnIntent.putIntegerArrayListExtra(ClickerActivity.SELECT_POINTS_ACTIVITY_RESULT, mXYCoordinates);
    setResult(Activity.RESULT_OK, returnIntent);
    finish();
}
 
Example 12
Source File: SystemArticlesActivity.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 给其他活动需要传入数据并跳转到该活动时调用
 *
 * @param context              活动
 * @param firstSystemName      一级知识的名字
 * @param secondSystemNameList 二级知识的名字集合
 * @param idList               二级知识的id集合
 */
public static void startActivityByData(Context context,
                                       String firstSystemName,
                                       List<String> secondSystemNameList,
                                       List<Integer> idList) {
    Intent intent = new Intent(context, SystemArticlesActivity.class);
    intent.putExtra(KEY_SYSTEM_FIRST_NAME, firstSystemName);
    intent.putStringArrayListExtra(KEY_SYSTEM_SECOND_NAME_LIST, (ArrayList<String>) secondSystemNameList);
    intent.putIntegerArrayListExtra(KEY_SYSTEM_SECOND_ID_LIST, (ArrayList<Integer>) idList);
    context.startActivity(intent);
}
 
Example 13
Source File: PlaylistFragment.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Launches the {@link com.jarekandshawnmusic.m.MediaPlayerService}
 * to play the requested playlist, or re-initializes an existing
 * {@link com.jarekandshawnmusic.m.MediaPlayerService} with a new playlist.
 * @param playlist the list of songs to play
 */
public void setPlaylist(ArrayList<Integer> playlist) {
    if (mBound) {
        mMediaPlayerService.setPlaylist(playlist);
        mMediaPlayerService.play();
    } else {
        Activity containerActivity = getActivity();
        Intent playlistIntent = new Intent(containerActivity, MediaPlayerService.class);
        playlistIntent.putIntegerArrayListExtra("playlist", playlist);
        containerActivity.startService(playlistIntent);
        // We start this service and then bind to it, so we can control the playback
        // and get progress updates.
        containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE);
    }
}
 
Example 14
Source File: Main.java    From currency with GNU General Public License v3.0 5 votes vote down vote up
private boolean onChartClick()
{
    Intent intent = new Intent(this, ChartActivity.class);
    List<Integer> list = new ArrayList<>();

    // Add the current index
    list.add(currentIndex);

    // Add the select list to the list
    for (int index : selectList)
    {
        String name = nameList.get(index);
        list.add(currencyNameList.indexOf(name));
    }

    // Put the list
    intent.putIntegerArrayListExtra(CHART_LIST,
                                    (ArrayList<Integer>) list);

    // Start chart activity
    startActivity(intent);

    // Clear select list and update adapter
    selectList.clear();
    adapter.notifyDataSetChanged();

    // Restore menu
    mode = DISPLAY_MODE;
    invalidateOptionsMenu();

    return true;
}
 
Example 15
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 5 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with too big coordinates</i>
 */
@Test
public void startServiceWithToBigCoordinates() {

    l(this, "@Test startServiceWithToBigCoordinates");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(Integer.MAX_VALUE); // x0
    points.add(Integer.MAX_VALUE); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 16
Source File: BgdService2.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
private void startConfirmAty(TargetInfo tInfo) {
	if (tInfo != null && tInfo.getQlnInfo() != null && mCurrMInfo != null){
		showMsg("抢票监控已检测到可用票"+SF.SUCCESS);
		MyApp.getInstance().setBgdBInfo(mBgdBInfo);
		Intent intent = new Intent(getApplicationContext(), ConfirmPassengerAty.class);
		intent.putExtra(ConfirmPassengerAty.EXTRA_TRAIN_INFO, tInfo.getQlnInfo().getQueryLeftNewDTO());
		intent.putExtra(ConfirmPassengerAty.EXTRA_TOUR_FLAG, TT.getTour_flags().get("dc"));
		intent.putExtra(ConfirmPassengerAty.EXTRA_MODE, ConfirmPassengerAty.EXTRA_MODE_MONITOR);
		intent.putIntegerArrayListExtra(ConfirmPassengerAty.EXTRA_P_NATIVE_INDEXS, (ArrayList<Integer>)mCurrMInfo.getLstPNativeIndexes());
		intent.putExtra(ConfirmPassengerAty.EXTRA_DEFAULT_SEAT_TYPE, tInfo.getSeatType());
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(intent);
	}
}
 
Example 17
Source File: PlaylistFragment.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Launches the {@link com.jarekandshawnmusic.m.MediaPlayerService}
 * to play the requested playlist, or re-initializes an existing
 * {@link com.jarekandshawnmusic.m.MediaPlayerService} with a new playlist.
 * @param playlist the list of songs to play
 */
public void setPlaylist(ArrayList<Integer> playlist) {
    if (mBound) {
        mMediaPlayerService.setPlaylist(playlist);
        mMediaPlayerService.play();
    } else {
        Activity containerActivity = getActivity();
        Intent playlistIntent = new Intent(containerActivity, MediaPlayerService.class);
        playlistIntent.putIntegerArrayListExtra("playlist", playlist);
        containerActivity.startService(playlistIntent);
        // We start this service and then bind to it, so we can control the playback
        // and get progress updates.
        containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE);
    }
}
 
Example 18
Source File: FaBoVirtualServiceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * プロファイル選択画面を開きます.
 */
private void openProfileActivity() {
    ArrayList<ProfileData> list = new ArrayList<>();
    for (ProfileData p : mServiceData.getProfileDataList()) {
        list.add(p);
    }
    Intent intent = new Intent();
    intent.setClass(this, FaBoProfileListActivity.class);
    intent.putParcelableArrayListExtra("profile", list);
    intent.putIntegerArrayListExtra("pins", new ArrayList<>(getUsePins()));
    startActivityForResult(intent, REQUEST_CODE_ADD_PROFILE);
}
 
Example 19
Source File: GetContactsFragment.java    From BlackList with Apache License 2.0 5 votes vote down vote up
@Override
protected void addContacts(List<Contact> contacts, LongSparseArray<ContactNumber> singleContactNumbers) {
    // prepare returning arguments - data of the chosen contacts
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> numbers = new ArrayList<>();
    ArrayList<Integer> types = new ArrayList<>();
    for (Contact contact : contacts) {
        ContactNumber contactNumber = singleContactNumbers.get(contact.id);
        if (contactNumber != null) {
            // add single number of the contact
            names.add(contact.name);
            numbers.add(contactNumber.number);
            types.add(contactNumber.type);
        } else {
            // all numbers of the contact
            for (ContactNumber _contactNumber : contact.numbers) {
                names.add(contact.name);
                numbers.add(_contactNumber.number);
                types.add(_contactNumber.type);
            }
        }
    }

    // return arguments
    Intent intent = new Intent();
    intent.putStringArrayListExtra(CONTACT_NAMES, names);
    intent.putStringArrayListExtra(CONTACT_NUMBERS, numbers);
    intent.putIntegerArrayListExtra(CONTACT_NUMBER_TYPES, types);
    getActivity().setResult(Activity.RESULT_OK, intent);
    getActivity().finish();
}
 
Example 20
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 4 votes vote down vote up
/**
     * Tests the service start method without well formed intent
     *
     * <i>The clicker service can be started from the outside with a dedicated intent with numerous values inside</i>
     * <i>Once started the clicker service have to make notifications displayed</i>
     */
    @Test
    public void startService(){

        l(this, "@Test startService");

        Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
        // Create the Intent with the good action
        startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");

        // Defines the configuration to use
        startIntent.putExtra("0x000011", true); // Start delayed ?
        startIntent.putExtra("0x000012", 20);   // How much delay for the start ?
        startIntent.putExtra("0x000013", 2);    // The amount of time to wait between clicks
        startIntent.putExtra("0x000021", 10);    // The number of repeat to do
        startIntent.putExtra("0x000022", false);// Endless repeat ?
        startIntent.putExtra("0x000031", false);// Vibrate on start ?
        startIntent.putExtra("0x000032", false);// Vibrate on each click ?
        startIntent.putExtra("0x000041", true);// Make notifications ?
        ArrayList<Integer> points = new ArrayList<>();
        points.add(695); // x0
        points.add(799); // y0
        startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points

        try {
            mServiceRule.startService( startIntent );
        } catch ( TimeoutException te ){
            // Do nothing, it can rise even if the service is working properly
        }

        // Test the countdown notification
        testNotification(mContext.getString(R.string.notif_content_text_countdown));

        w(10000);

        // Test the new click notification
        testNotification(mContext.getString(R.string.notif_content_text_click_made));

        w(5000);

        // Test the on going process notification
        testNotification(mContext.getString(R.string.notif_content_text_clicks_on_going_service));

        w(10000);

        // Test the terminated notification
//        testNotification(mContext.getString(R.string.notif_content_text_clicks_over));

    }