title: Get data value from Fragment into Main activity?
body: <p>I am trying to create a notification badge like Whatsapp (Near tabs) but unable to fetch data value which are stored in a fragment but as the badge would be in the main activity, I'm unable to get(call) the dynamic value from the fragment.</p>
  
  <p>Below are the codes:</p>
  
  <blockquote>
    <p>LoadJSON Code</p>
  </blockquote>
  
  <pre><code>private void loadJSONClaim() {
      sp = this.getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
      String usr = sp.getString(UserID, "");
      Retrofit retrofitclaim = new Retrofit.Builder()
              .baseUrl("http://ec2-54-191-118-200.us-west-2.compute.amazonaws.com/")
              .addConverterFactory(GsonConverterFactory.create())
              .build();
  
      RequestInterfaceClaim requestclaim = retrofitclaim.create(RequestInterfaceClaim.class);
      Call&lt;JSONResponseClaim&gt; call = requestclaim.getJSONClaim(usr);
      call.enqueue(new Callback&lt;JSONResponseClaim&gt;() {
          @Override
          public void onResponse(Call&lt;JSONResponseClaim&gt; call, Response&lt;JSONResponseClaim&gt; responseclaim) {
  
              JSONResponseClaim jsonResponseClaim = responseclaim.body();
              dataclaim = new ArrayList&lt;&gt;(Arrays.asList(jsonResponseClaim.getAndroidClaim()));
              adapterclaim = new DataAdapterClaim(dataclaim);
              mRecyclerViewClaim.setAdapter(adapterclaim);
              eligitem.setText("    Eligible to earn   " + dataclaim.size() + " items");
            /* if(dataclaim.size()==0){
                  filldata.setVisibility(View.GONE);
                  emptyclaim.setVisibility(View.VISIBLE);
              }
              else{
                  emptyclaim.setVisibility(View.GONE);
                  filldata.setVisibility(View.VISIBLE);
  
              }*/
          }
  </code></pre>
  
  <p>So either the below code works in Fragment or data values get called in Main activity shouldresolve the issue, I guess.</p>
  
  <blockquote>
    <p>MainActivity.java</p>
  </blockquote>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      CleverTapAPI ct;
  
      BadgeView badgeView = new BadgeView(this,tabLayout);
      badgeView.setText("2");
      badgeView.show();
  </code></pre>
  
  <p>Can anybody help on this?</p>
  
  <p>EDIT: refined question</p>