Problem with getting id from bundle in android











up vote
0
down vote

favorite












i am having problem in getting the id in second activity, i am passing id in bundle like below in first activity



Bundle bundle = new Bundle();
bundle.putInt(Constants.ID, featured.getId());
bundle.putString(Constants.TITLE, "Team");
openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );


but when i am getting the id in the second activity, it is showing me zero here



 uid = getIntent().getBundleExtra(Constants.DATA).getInt(Constants.ID);


please suggests something.










share|improve this question
























  • Simply use getIntent().getExtras().getInt(Constants.ID)
    – Piyush
    Nov 20 at 7:00










  • ok let me check
    – S.H
    Nov 20 at 7:01






  • 1




    You aren't sending bundle to the intent.
    – jack jay
    Nov 20 at 7:05










  • have you put bundle to intent already ?
    – Truong Giang Dam
    Nov 20 at 7:06










  • where @TruongGiangDam ?
    – S.H
    Nov 20 at 7:10















up vote
0
down vote

favorite












i am having problem in getting the id in second activity, i am passing id in bundle like below in first activity



Bundle bundle = new Bundle();
bundle.putInt(Constants.ID, featured.getId());
bundle.putString(Constants.TITLE, "Team");
openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );


but when i am getting the id in the second activity, it is showing me zero here



 uid = getIntent().getBundleExtra(Constants.DATA).getInt(Constants.ID);


please suggests something.










share|improve this question
























  • Simply use getIntent().getExtras().getInt(Constants.ID)
    – Piyush
    Nov 20 at 7:00










  • ok let me check
    – S.H
    Nov 20 at 7:01






  • 1




    You aren't sending bundle to the intent.
    – jack jay
    Nov 20 at 7:05










  • have you put bundle to intent already ?
    – Truong Giang Dam
    Nov 20 at 7:06










  • where @TruongGiangDam ?
    – S.H
    Nov 20 at 7:10













up vote
0
down vote

favorite









up vote
0
down vote

favorite











i am having problem in getting the id in second activity, i am passing id in bundle like below in first activity



Bundle bundle = new Bundle();
bundle.putInt(Constants.ID, featured.getId());
bundle.putString(Constants.TITLE, "Team");
openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );


but when i am getting the id in the second activity, it is showing me zero here



 uid = getIntent().getBundleExtra(Constants.DATA).getInt(Constants.ID);


please suggests something.










share|improve this question















i am having problem in getting the id in second activity, i am passing id in bundle like below in first activity



Bundle bundle = new Bundle();
bundle.putInt(Constants.ID, featured.getId());
bundle.putString(Constants.TITLE, "Team");
openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );


but when i am getting the id in the second activity, it is showing me zero here



 uid = getIntent().getBundleExtra(Constants.DATA).getInt(Constants.ID);


please suggests something.







java android bundle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 7:03









Aniruddh Parihar

2,16111027




2,16111027










asked Nov 20 at 6:59









S.H

226




226












  • Simply use getIntent().getExtras().getInt(Constants.ID)
    – Piyush
    Nov 20 at 7:00










  • ok let me check
    – S.H
    Nov 20 at 7:01






  • 1




    You aren't sending bundle to the intent.
    – jack jay
    Nov 20 at 7:05










  • have you put bundle to intent already ?
    – Truong Giang Dam
    Nov 20 at 7:06










  • where @TruongGiangDam ?
    – S.H
    Nov 20 at 7:10


















  • Simply use getIntent().getExtras().getInt(Constants.ID)
    – Piyush
    Nov 20 at 7:00










  • ok let me check
    – S.H
    Nov 20 at 7:01






  • 1




    You aren't sending bundle to the intent.
    – jack jay
    Nov 20 at 7:05










  • have you put bundle to intent already ?
    – Truong Giang Dam
    Nov 20 at 7:06










  • where @TruongGiangDam ?
    – S.H
    Nov 20 at 7:10
















Simply use getIntent().getExtras().getInt(Constants.ID)
– Piyush
Nov 20 at 7:00




Simply use getIntent().getExtras().getInt(Constants.ID)
– Piyush
Nov 20 at 7:00












ok let me check
– S.H
Nov 20 at 7:01




ok let me check
– S.H
Nov 20 at 7:01




1




1




You aren't sending bundle to the intent.
– jack jay
Nov 20 at 7:05




You aren't sending bundle to the intent.
– jack jay
Nov 20 at 7:05












have you put bundle to intent already ?
– Truong Giang Dam
Nov 20 at 7:06




have you put bundle to intent already ?
– Truong Giang Dam
Nov 20 at 7:06












where @TruongGiangDam ?
– S.H
Nov 20 at 7:10




where @TruongGiangDam ?
– S.H
Nov 20 at 7:10












2 Answers
2






active

oldest

votes

















up vote
0
down vote













Try



getIntent().getExtras().getInt(Constants.ID)
getIntent().getExtras().getString(Constants.TITLE)


may solve your problem.



Also let us know whats inside below function. Are you passing the bundle correctly to next activity via intent.



  `openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );`


It must contain some code as



intent.putExtras(bundle);





share|improve this answer























  • Constants.TITLE is String not int.
    – Piyush
    Nov 20 at 7:05


















up vote
0
down vote













Try this way..



uid = getIntent().getExtras().getInt(Constants.ID);


when called below line it give bundle object.



Bundle bundle = getIntent().getExtras();





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387771%2fproblem-with-getting-id-from-bundle-in-android%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Try



    getIntent().getExtras().getInt(Constants.ID)
    getIntent().getExtras().getString(Constants.TITLE)


    may solve your problem.



    Also let us know whats inside below function. Are you passing the bundle correctly to next activity via intent.



      `openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );`


    It must contain some code as



    intent.putExtras(bundle);





    share|improve this answer























    • Constants.TITLE is String not int.
      – Piyush
      Nov 20 at 7:05















    up vote
    0
    down vote













    Try



    getIntent().getExtras().getInt(Constants.ID)
    getIntent().getExtras().getString(Constants.TITLE)


    may solve your problem.



    Also let us know whats inside below function. Are you passing the bundle correctly to next activity via intent.



      `openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );`


    It must contain some code as



    intent.putExtras(bundle);





    share|improve this answer























    • Constants.TITLE is String not int.
      – Piyush
      Nov 20 at 7:05













    up vote
    0
    down vote










    up vote
    0
    down vote









    Try



    getIntent().getExtras().getInt(Constants.ID)
    getIntent().getExtras().getString(Constants.TITLE)


    may solve your problem.



    Also let us know whats inside below function. Are you passing the bundle correctly to next activity via intent.



      `openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );`


    It must contain some code as



    intent.putExtras(bundle);





    share|improve this answer














    Try



    getIntent().getExtras().getInt(Constants.ID)
    getIntent().getExtras().getString(Constants.TITLE)


    may solve your problem.



    Also let us know whats inside below function. Are you passing the bundle correctly to next activity via intent.



      `openAcitivty(getBundle("Questions" , (Serializable) featured.getAll().getQa()) , ProviderQAactivity.class );`


    It must contain some code as



    intent.putExtras(bundle);






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 20 at 7:07

























    answered Nov 20 at 7:03









    Nivedh

    739515




    739515












    • Constants.TITLE is String not int.
      – Piyush
      Nov 20 at 7:05


















    • Constants.TITLE is String not int.
      – Piyush
      Nov 20 at 7:05
















    Constants.TITLE is String not int.
    – Piyush
    Nov 20 at 7:05




    Constants.TITLE is String not int.
    – Piyush
    Nov 20 at 7:05












    up vote
    0
    down vote













    Try this way..



    uid = getIntent().getExtras().getInt(Constants.ID);


    when called below line it give bundle object.



    Bundle bundle = getIntent().getExtras();





    share|improve this answer

























      up vote
      0
      down vote













      Try this way..



      uid = getIntent().getExtras().getInt(Constants.ID);


      when called below line it give bundle object.



      Bundle bundle = getIntent().getExtras();





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Try this way..



        uid = getIntent().getExtras().getInt(Constants.ID);


        when called below line it give bundle object.



        Bundle bundle = getIntent().getExtras();





        share|improve this answer












        Try this way..



        uid = getIntent().getExtras().getInt(Constants.ID);


        when called below line it give bundle object.



        Bundle bundle = getIntent().getExtras();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 7:35









        Android Team

        7,32511033




        7,32511033






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387771%2fproblem-with-getting-id-from-bundle-in-android%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'