This is the code I have.
In my main .java file.
public void showQuiz (View view){
Username = (EditText) findViewById(R.id.Username);
String userId = Username.getText().toString();
String deviceId = Secure.getString(this.getContentResolver(),
Secure.ANDROID_ID);
//this intent is used to open other activity wich contains another webView
Intent intent = new Intent(this, Quiz.class);
Bundle bun = new Bundle();
bun.putString("userid",userId);
bun.putString("deviceid", deviceId);
intent.putExtras(bun);
startActivity(intent);
}
This is what is in the Activity’s .java file.
package com.earn.egpt;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Quiz extends Activity {
private static final String url = "http://www.m.s-w-family.com/?subid=";
private static final String url2 = "&deid=";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
Bundle extras=getIntent().getExtras();
String userId=extras.getString("userId");
String deviceId=extras.getString("deviceId");
WebView webview;
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url+userId+url2+deviceId);
}
}
for some reason it is passing the strings as null, but I have no idea why. I am extremely new to this kind of programming so I don’t even know where to being. I have looked at other problems similar to mine and tried the fixes for them, but the values are still null.
You are using an extra Bundle by accident. Put the extras directly into the Intent instead:
Now your
getString()methods will return what you want in Quiz.