0

I have a widget called "recordWidget.java" and I want it to opened on the home screen.

When a user clicks the button called "recordScreenButton" I want it go to the home screen and immediately open the widget on the homescreen.

public void recordScreenClick(View v) {
        if (v.getId() == R.id.recordScreenButton) { //if they click create
            finish();
            Intent intent = new Intent(Intent.ACTION_MAIN); //goes to homescreen
            Intent i = new Intent(create.this, 
            recordScreenActivity.class);
            Intent widget = new Intent(create.this,recordWidget.class);
            intent.addCategory(Intent.CATEGORY_HOME);
            startActivity(intent);
            startActivity(i);
            startActivity(widget);
    }


}

I thought I could open it like any other activity with intent, but I cannot. What else can I use besides intent?

1 Answers1

0

You can't make this logic on devices pre Oreo. New API on O let you make a widget on homescreen programmatically. Just checkout my previous answer

HeyAlex
  • 1,666
  • 1
  • 13
  • 31