Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's the solution for this. Declare a String before your <code>onCreate()</code> Method but inside the class like this -</p> <pre><code>public static final String pass="com.your.application._something"; </code></pre> <p>In your <code>publishArrived</code> method,you can do this -</p> <pre><code>String s="Pass this String";//If you want to pass an string int id=10;//If you want to pass an integer Intent i=new Intent(currentactivity.this,NewActivity.class); i.putExtra(pass, id);//If you want to pass the string use i.putExtra(pass, s); startActivity(i); </code></pre> <p>And now you want to catch the data which this activity provided. So, In the new activity, simply extract the value as shown - </p> <pre><code>//this is for getting integer. int a=getIntent().getExtras().getInt(CurrentActivity.pass); //this is for getting String String s=getIntent().getExtras(CurrentActivity.pass); </code></pre> <p>Note 1 : Actually always String should be passed as it can easily pe parsed as Integer.</p> <p>Note 2 : Give your CurrentActivity and NewActivity name in the respective places.</p> <p>Hope this helps.</p> <p>In your case suppose the Login is "abc" and the password is "pqr" then you can pass this as <code>String s=login+"*"+password;</code> This will result in abc*pqr</p> <p>Now in the NewActivity simply parse the String till you get '*'.Get its Index by <code>indexOf('*')</code>. The value before this index is the Login and the value after this will be the password.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload