以下代码可以正常工作,没有任何错误,但是当我尝试通过意图获取 url 时,我收到应用程序意外停止的错误。谁能帮帮我。
public class MjpegSample extends Activity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String URL = "http://121.6.98.160:8081/videostream.cgi?"
+ "user=admin&pwd=admin&resolution=8";
}
}
当我替换上面的代码时,下面的代码会出错:
public class MjpegSample extends Activity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String URL;
Bundle extras = getIntent().getExtras();
URL = extras.getString("flink");
}
}
为了通过意图获得“flink”,我使用以下内容
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1 = (Button) findViewById(R.id.viewcam);
t=(EditText)findViewById(R.id.username);
p=(EditText)findViewById(R.id.password);
i=(EditText)findViewById(R.id.ip);
po=(EditText)findViewById(R.id.port);
b1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
String tt=t.getText().toString();
String pp=p.getText().toString();
String ii=i.getText().toString();
String por=po.getText().toString();
String link="http://"+ii+":"+por
+"/videostream.cgi?user="+tt
+"&pwd="+pp+"resolution=8";
Intent myIntent = new Intent(v.getContext(), MjpegSample.class);
myIntent.putExtra("flink",link);
startActivityForResult(myIntent, 0);
}
});
}