在模拟器上打开第一个活动没有问题,但问题是当按下按钮时
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainlayoutActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
final Button man = (Button) findViewById(R.id.getDATA);
man.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainlayoutActivity.this, second.class);
startActivityForResult(i, 77);
}
});
}
public void onActivityResult(int requstCode, int resultCode, Intent data) {
if ((requstCode == 77) && (resultCode == Activity.RESULT_OK)) {
String gett = data.getExtras().getString("TEXT value");
Toast.makeText(this, gett, Toast.LENGTH_LONG).show();
}
}
}
问题是在模拟器上启动第二个活动
public class second extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seconlayout);
final Button btn = (Button) findViewById(R.id.GDATA);
final EditText ed = (EditText) findViewById(R.id.value);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String word = ed.getText().toString();
Intent i = new Intent();
i.putExtra("TEXT value", word);
setResult(Activity.RESULT_OK, i);
finish();
}
});
}
}
清单文件
<? xml version = "1.0"encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.l9"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.example.l9.MainlayoutActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.example.l9.second">
<intent-filter>
<action android:name="net.abdullaheid.action.ToDATA"/>
<category android:name="android.intent.categor.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
import redis
r_server = redis.Redis("localhost")
r_server.rpush("requests", "Adam")
r_server.rpush("requests", "Bob")
r_server.rpush("requests", "Carol")
print r_server.lrange("requests", 0, -1)
print r_server.llen("requests")
print r_server.lindex("requests", 1)
如果您不想从此活动转移,则此参数无效。您需要使用参数创建Intent
Intent intent = new Intent();
。
所以,你得到错误,因为你的Intent()构造函数是空的。