android.content.Intent#putIntegerArrayListExtra ( )源码实例Demo

下面列出了android.content.Intent#putIntegerArrayListExtra ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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;
}
 
/**
 * 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;
}
 
源代码3 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码4 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码5 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码6 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码7 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码8 项目: 365browser   文件: InvalidationIntentProtocol.java
/**
 * 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;
}
 
源代码9 项目: Zom-Android-XMPP   文件: ContactsPickerActivity.java
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();
    }
}
 
源代码10 项目: Yuan-WanAndroid   文件: SystemArticlesActivity.java
/**
 * 给其他活动需要传入数据并跳转到该活动时调用
 *
 * @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);
}
 
源代码11 项目: BlackList   文件: GetContactsFragment.java
@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();
}
 
源代码12 项目: Huochexing12306   文件: BgdService2.java
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);
	}
}
 
源代码13 项目: currency   文件: Main.java
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;
}
 
源代码14 项目: io2014-codelabs   文件: PlaylistFragment.java
/**
 * 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);
    }
}
 
源代码15 项目: currency   文件: ChoiceDialog.java
@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;
    }
}
 
源代码16 项目: SmoothClicker   文件: SelectMultiPointsActivity.java
/**
 * 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();
}
 
源代码17 项目: SmoothClicker   文件: ItServiceClicker.java
/**
 * 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();}

}
 
源代码18 项目: io2014-codelabs   文件: PlaylistFragment.java
/**
 * 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);
    }
}
 
/**
 * プロファイル選択画面を開きます.
 */
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);
}
 
源代码20 项目: SmoothClicker   文件: ItServiceClicker.java
/**
     * 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));

    }
 
 方法所在类
 同类方法