Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:11:28+00:00 2026-06-14T17:11:28+00:00

I am trying develop an android application for a device (device is not a

  • 0

I am trying develop an android application for a device (device is not a tablet or phone, its a preconfigured android board running Android 4.1.1)and one of the activity need to display a customized dashboard of several types of information as shown below
enter image description here

The types of information shown here is preconfigured. Instead of developing all these from scratch, I am planning to install apps that has widgets (like weather and calendar) and include widgets in my Layout.

I refered to the below links

Add widgets into my own application.- Android

http://www.anddev.org/appwidgethost_tutorial-t10329.html

I completed most of my code.

public class MainActivity extends Activity {


    private AppWidgetManager mAppWidgetManager;
    private AppWidgetHost mAppWidgetHost;
    static final int APPWIDGET_HOST_ID = 2037;
    private AppWidgetHostView widgets[] = new AppWidgetHostView[16];



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mAppWidgetManager = AppWidgetManager.getInstance(this);
        mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);

        setContentView(r.id.layout_main);


    ****here is where I am stuck??****
        int [] ids = AppWidgetManager.getInstance(context).getAppWidgetIds(name);


        mAppWidgetHost.startListening();

    }

But the place where I am stuck is, how do I specify widget manager to get the specific widget I want. Let us say I am interested in the widget
“com.android.deskclock/com.android.alarmclock.AnalogAppWidgetProvider”

Please advice.


Update:
I added the below code

 mAppWidgetManager = AppWidgetManager.getInstance(this);
        mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);
        int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
        ComponentName name = new ComponentName("com.android.deskclock","com.android.alarmclock.AnalogAppWidgetProvider");

        int [] ids = mAppWidgetManager.getAppWidgetIds(name);

        if(ids != null && ids.length>0){
            System.err.println("Number of widget ids :"+ids.length);
            AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(ids[0]);
            appWidgetId = ids[0];
            LinearLayout parent= (LinearLayout) findViewById(R.id.generalDashboardLayout);
            parent.addView(mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo));
        }else{
            System.err.println("Ids is null");
        }

It always prints “Ids is null” It is not finding the widget to add to my view

Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:11:30+00:00Added an answer on June 14, 2026 at 5:11 pm

    Finally I solved the issue by using the below code

    mAppWidgetManager = AppWidgetManager.getInstance(this);
            mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);
            int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
            ComponentName name = new ComponentName("com.android.deskclock","com.android.alarmclock.AnalogAppWidgetProvider");
    
            int [] ids = mAppWidgetManager.getAppWidgetIds(name);
    
            if(ids != null && ids.length>0){
                System.err.println("Number of widget ids :"+ids.length);
                AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(ids[0]);
                appWidgetId = ids[0];
                LinearLayout parent= (LinearLayout) findViewById(R.id.generalDashboardLayout);
                parent.addView(mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo));
            }else{
                System.err.println("Ids is null");
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to develop an Android 3.1 tablet application. This app will have a
I’m trying to develop an Android application for a medical device using Bluetooth (SPP).
I'm trying to develop an Android app. I'm developing in Eclipse which is running
I am trying to develop an Android based application, which can play video from
I'm trying to develop an application for android with NFC-tags. When I find a
I'm trying to develop an application launcher application for android. I'm in the very
I'm trying to develop an Audio Capture application using the AudioRecord class from android
I'm trying to develop an application on phonegap on Android. What I'm trying to
I am trying to develop a custom stop watch application in android but it
I am new to android. I am trying to develop android helloworld application as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.