1. Are you ready for the Galaxy S20? Here is everything we know so far!

multiple widget instance sending parameters to app

Discussion in 'Android Development' started by Poulette, Jun 14, 2019.

  1. Poulette

    Poulette Lurker
    Thread Starter

    Hello,

    I have one widget and one separated app


    The widget can launch the application by passing parameters

    typically I put 3 times the same widget on my home page with 3 different settings, for example A B and C

    When I click on my first widget A, the application opens and receives the parameter A, good !!!
    but now if I click on widget B, the application switches to foreground but does not receive parameter B


    I think I know why, but I can not find a workaround:



    ----------------------------------------------------------
    In my widget I have this code to apen the app :

    Intent intentAppli = new Intent(Intent.ACTION_MAIN);
    intentAppli.addCategory(Intent.CATEGORY_LAUNCHER);
    intentAppli.putExtra("system_to_show", system);
    intentAppli.setClassName("com.santeos.meteoSanteos", "com.santeos.meteoSanteos.MainActivity");
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intentAppli, PendingIntent.FLAG_UPDATE_CURRENT);

    views.setOnClickPendingIntent(R.id.id_projet, pendingIntent);


    ----------------------------------------------------------------
    in my app I have in the onCreate
    Bundle extras = getIntent().getExtras();
    if(extras == null) {
    systemToShow= null;
    } else {
    systemToShow= extras.getString("system_to_show");
    }

    if(systemToShow!=null)
    {
    //TODO here get the string stored in the string variable and do
    // setText() on userName

    Toast.makeText(MainActivity.this,systemToShow, Toast.LENGTH_LONG).show();
    baseUrl=baseUrl+"&toshow="+systemToShow;
    }


    Here I understand that it will work only when creating the app.


    But I have tryed to move this code in the onResume and I always have the first parameter use to launch the app first time, and never the second one or third....


    It seems that the intent is never updated with the extra parameter



    Thanks for any help !!!
    Best regards,
    Laurent
     


Loading...
Similar Threads - multiple widget instance
  1. App Update
    Replies:
    0
    Views:
    141
  2. Brainsoft
    Replies:
    2
    Views:
    273
  3. ABHISHEKRKM
    Replies:
    0
    Views:
    167
  4. aapeppin
    Replies:
    2
    Views:
    355
  5. Mahmudul001
    Replies:
    0
    Views:
    505
  6. SRT GmbH
    Replies:
    5
    Views:
    1,001
  7. RaoulH
    Replies:
    0
    Views:
    394
  8. TimoW96
    Replies:
    0
    Views:
    353
  9. afahskljlhdsfgfjfgj
    Replies:
    0
    Views:
    344

Share This Page

Loading...