Code example for AppWidgetHost

Methods: startListening

0
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        mAppWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
        mAppWidgetHost = new AppWidgetHost(getApplicationContext(), APPWIDGET_HOST_ID);
        //开始监听widget的变化 
        mAppWidgetHost.startListening();
         
        layout = new WidgetLayout(this);
        layout.setOnLongClickListener(new OnLongClickListener() {
			 
			@Override 
			public boolean onLongClick(View v) {
				 
				addWidget(); 
				return false; 
			} 
		}); 
        setContentView(layout);
Stop searching for code, let great code find you!  Add Codota to your java IDE