Android AppWidgetHost - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AppWidgetHost class.

This code example shows how to use the following methods:createView, deleteAppWidgetId
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteHost
                    "displayMode INTEGER" + 
                    ");"); 
 
            // Database was just created, so wipe any previous widgets 
            if (mAppWidgetHost != null) {
                mAppWidgetHost.deleteHost();
                sendAppWidgetResetNotify(); 
            } 
 
            if (!convertDatabase(db)) {
                // Set a shared pref so that we know we need to load the default workspace later 
                setFlagToLoadDefaultWorkspaceLater(); 
            } 
        } 
 
        private void setFlagToLoadDefaultWorkspaceLater() { 
            String spKey = LauncherApplication.getSharedPreferencesKey();
            SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.putBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, true);
2
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:startListening
    public void startUpdate(View arg0) {
    } 
 
    public void onShow() { 
        if (mAppWidgetHost != null) {
            mAppWidgetHost.startListening();
        } 
    } 
 
    public void onHide() { 
        if (mAppWidgetHost != null) {
            mAppWidgetHost.stopListening();
        } 
    } 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteHost
                    "sortType INTEGER" + 
                    ");"); 
 
            // Database was just created, so wipe any previous widgets 
            if (mAppWidgetHost != null) {
                mAppWidgetHost.deleteHost();
                sendAppWidgetResetNotify(); 
            } 
 
            if (!convertDatabase(db)) {
                // Set a shared pref so that we know we need to load the default workspace later 
                setFlagToLoadDefaultWorkspaceLater(); 
            } 
        } 
 
        private void setFlagToLoadDefaultWorkspaceLater() { 
            String spKey = LauncherApplication.getSharedPreferencesKey();
            SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.putBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, true);
2
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteHost
                    "icon BLOB" + 
                    ");"); 
 
            // Database was just created, so wipe any previous widgets 
            if (mAppWidgetHost != null) {
                mAppWidgetHost.deleteHost();
                sendAppWidgetResetNotify(); 
            } 
             
            if (!convertDatabase(db)) {
                // Populate favorites table with initial favorites 
                loadFavorites(db);
            } 
        } 
 
        private boolean convertDatabase(SQLiteDatabase db) {
            if (LOGD) Log.d(LOG_TAG, "converting database from an older format, but not onUpgrade");
            boolean converted = false;
 
            final Uri uri = Uri.parse("content://" + Settings.AUTHORITY +
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteHost
                    "icon BLOB" + 
                    ");"); 
 
            // Database was just created, so wipe any previous widgets 
            if (mAppWidgetHost != null) {
                mAppWidgetHost.deleteHost();
                sendAppWidgetResetNotify(); 
            } 
 
            if (!convertDatabase(db)) {
                // Set a shared pref so that we know we need to load the default workspace later 
                setFlagToLoadDefaultWorkspaceLater(); 
            } 
        } 
 
        private void setFlagToLoadDefaultWorkspaceLater() { 
            String spKey = LauncherApplication.getSharedPreferencesKey();
            SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.putBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, true);
2
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:allocateAppWidgetId, createView
		aa(); 
 
	} 
 
	private void aa() { 
		id = host.allocateAppWidgetId();
		AppWidgetProviderInfo appWidgetProviderInfo = widgetList.get(1);
		boolean success = false;
		success = appWidgetManager.bindAppWidgetIdIfAllowed(id,
				appWidgetProviderInfo.provider);
		if (success) {
			AppWidgetHostView hostView = host.createView(
					WidgetShowActivity.this, id, appWidgetProviderInfo);
			linearlayout.addView(hostView);
		} else { 
			Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
			intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER,
					appWidgetProviderInfo.provider);
			// TODO: we need to make sure that this accounts for the options 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteHost
                    "displayMode INTEGER" + 
                    ");"); 
 
            // Database was just created, so wipe any previous widgets 
            if (mAppWidgetHost != null) {
                mAppWidgetHost.deleteHost();
                sendAppWidgetResetNotify(); 
            } 
             
            if (!convertDatabase(db)) {
                // Populate favorites table with initial favorites 
                loadFavorites(db);
            } 
        } 
 
        private boolean convertDatabase(SQLiteDatabase db) {
            if (LOGD) Log.d(TAG, "converting database from an older format, but not onUpgrade");
            boolean converted = false;
 
            final Uri uri = Uri.parse("content://" + Settings.AUTHORITY +
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:startListening
    @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);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteAppWidgetId
		btn.setOnClickListener(new OKBtnOnClickListener());
 
	} 
 
	public void removeWidget(int appWidgetId) {
		AppWidgetHost host = new AppWidgetHost(this, 1);
		host.deleteAppWidgetId(appWidgetId);
		host.deleteAppWidgetId(appWidgetId);
	} 
	 
	Boolean Canceled = true; 
	  
	@Override  
	protected void onPause() {  
		if(Canceled){
			//removeWidget(mAppWidgetId); 
		} 
		 
		super.onPause();  
	}  
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android AppWidgetHost Questions & Answers:

See Code Examples for Android AppWidgetHost Methods: