当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetHostView.getAppWidgetId方法代码示例

本文整理汇总了Java中android.appwidget.AppWidgetHostView.getAppWidgetId方法的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetHostView.getAppWidgetId方法的具体用法?Java AppWidgetHostView.getAppWidgetId怎么用?Java AppWidgetHostView.getAppWidgetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.appwidget.AppWidgetHostView的用法示例。


在下文中一共展示了AppWidgetHostView.getAppWidgetId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    WidgetAddFlowHandler addFlowHandler = info.getHandler();
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, addFlowHandler);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, addFlowHandler);
        } else {
            addFlowHandler.startBindFlow(this, appWidgetId, info, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:32,代码来源:Launcher.java

示例2: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, info.info, info));
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(info.info)
                .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:42,代码来源:Launcher.java

示例3: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
        int[] cell, int[] span) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = null;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo)
                .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:57,代码来源:Launcher.java

示例4: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 * 
 * @param info
 *            The PendingAppWidgetInfo of the widget being added.
 * @param screenId
 *            The ID of the screen where it should be added
 * @param cell
 *            The cell it should be added to, optional
 * @param position
 *            The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container,
		long screenId, int[] cell, int[] span, int[] loc) {
	resetAddInfo();
	mPendingAddInfo.container = info.container = container;
	mPendingAddInfo.screenId = info.screenId = screenId;
	mPendingAddInfo.dropPos = loc;
	mPendingAddInfo.minSpanX = info.minSpanX;
	mPendingAddInfo.minSpanY = info.minSpanY;

	if (cell != null) {
		mPendingAddInfo.cellX = cell[0];
		mPendingAddInfo.cellY = cell[1];
	}
	if (span != null) {
		mPendingAddInfo.spanX = span[0];
		mPendingAddInfo.spanY = span[1];
	}

	AppWidgetHostView hostView = info.boundWidget;
	int appWidgetId;
	if (hostView != null) {
		appWidgetId = hostView.getAppWidgetId();
		addAppWidgetImpl(appWidgetId, info, hostView, info.info);
	} else {
		// In this case, we either need to start an activity to get
		// permission to bind
		// the widget, or we need to start an activity to configure the
		// widget, or both.
		appWidgetId = getAppWidgetHost().allocateAppWidgetId();
		Bundle options = info.bindOptions;

		boolean success = false;
		if (options != null) {
			success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
					appWidgetId, info.componentName, options);
		} else {
			success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
					appWidgetId, info.componentName);
		}
		if (success) {
			addAppWidgetImpl(appWidgetId, info, null, info.info);
		} else {
			mPendingAddWidgetInfo = info.info;
			Intent intent = new Intent(
					AppWidgetManager.ACTION_APPWIDGET_BIND);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
					appWidgetId);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER,
					info.componentName);
			// TODO: we need to make sure that this accounts for the options
			// bundle.
			// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS,
			// options);
			startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
		}
	}
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:70,代码来源:Launcher.java

示例5: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
        int[] cell, int[] span) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = null;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo)
                .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:63,代码来源:Launcher.java

示例6: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
        int[] cell, int[] span, int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo)
                .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:55,代码来源:Launcher.java

示例7: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param cell The cell it should be added to, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container,
                          int[] cell, int[] span, int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
                appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo)
                    .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:krajeswaran,项目名称:LeanLauncher,代码行数:52,代码来源:Launcher.java

示例8: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
        int[] cell, int[] span, int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = false;
        if (options != null) {
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,
                    info.componentName, options);
        } else {
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,
                    info.componentName);
        }
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}
 
开发者ID:Lesik,项目名称:open-gel-plus,代码行数:59,代码来源:Launcher.java

示例9: addAppWidgetFromDrop

import android.appwidget.AppWidgetHostView; //导入方法依赖的package包/类
/**
 * Process a widget drop.
 * 
 * @param info
 *            The PendingAppWidgetInfo of the widget being added.
 * @param screen
 *            The screen where it should be added
 * @param cell
 *            The cell it should be added to, optional
 * @param position
 *            The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container,
		int screen, int[] cell, int[] span, int[] loc) {
	resetAddInfo();
	mPendingAddInfo.container = info.container = container;
	mPendingAddInfo.screen = info.screen = screen;
	mPendingAddInfo.dropPos = loc;
	mPendingAddInfo.minSpanX = info.minSpanX;
	mPendingAddInfo.minSpanY = info.minSpanY;

	if (cell != null) {
		mPendingAddInfo.cellX = cell[0];
		mPendingAddInfo.cellY = cell[1];
	}
	if (span != null) {
		mPendingAddInfo.spanX = span[0];
		mPendingAddInfo.spanY = span[1];
	}

	AppWidgetHostView hostView = info.boundWidget;
	int appWidgetId;
	if (hostView != null) {
		appWidgetId = hostView.getAppWidgetId();
		addAppWidgetImpl(appWidgetId, info, hostView, info.info);
	} else {
		// In this case, we either need to start an activity to get
		// permission to bind
		// the widget, or we need to start an activity to configure the
		// widget, or both.
		appWidgetId = getAppWidgetHost().allocateAppWidgetId();
		Bundle options = info.bindOptions;

		boolean success = false;
		if (success) {
			addAppWidgetImpl(appWidgetId, info, null, info.info);
		} else {
			mPendingAddWidgetInfo = info.info;
			Intent intent = new Intent(
					AppWidgetManager.ACTION_APPWIDGET_BIND);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
					appWidgetId);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER,
					info.componentName);
			startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
		}
	}
}
 
开发者ID:Kwamecorp,项目名称:Fairphone,代码行数:59,代码来源:Launcher.java


注:本文中的android.appwidget.AppWidgetHostView.getAppWidgetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。