我构建了一个从一个活动切换到另一个活动的代码。运行此代码时,它会打印以下错误。 XML 文件中的错误:正在中止构建。 和 安装错误:INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID 这是我的 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wishme.code"
android:versionCode="1"
android:versionName="1.0" android:sharedUserId="@string/app_name">
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".WishMeActivity"
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=".Activity2"></activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
这是活动1
package wishme.code;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Contacts.Intents;
import android.widget.TextView;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;
public class WishMeActivity extends Activity {
private EditText text;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text=(EditText) findViewById(R.id.editText1);
}
public void myClickhandler(View view)
{
switch(view.getId())
{
case R.id.button1:
RadioButton celsiusbutton=(RadioButton) findViewById(R.id.radio0);
RadioButton fahrenheit=(RadioButton) findViewById(R.id.radio2);
if(text.getText().length()==0)
{
Toast.makeText(this,"Enter a Valid Value",Toast.LENGTH_LONG).show();
return;
}
float input=Float.parseFloat(text.getText().toString());
if(celsiusbutton.isChecked())
{text.setText(String.valueOf(convertFahrenheitToCelsius(input)));
celsiusbutton.setChecked(false);
fahrenheit.setChecked(true);}
else
{
text.setText(String.valueOf(convertCelsiusToFahrenheit(input)));
fahrenheit.setChecked(false);
celsiusbutton.setChecked(true);
}
break;
case R.id.button_nxt:
Intent myintent=new Intent(view.getContext(),Activity2.class);
startActivityForResult(myintent, 0);
break;
}
}
private float convertFahrenheitToCelsius(float fahrenheit) {
return ((fahrenheit - 32) * 5 / 9);
}
// Converts to fahrenheit
private float convertCelsiusToFahrenheit(float celsius) {
return ((celsius * 9) / 5) + 32;
}
}
最后这是活动 2
package wishme.code;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity2 extends Activity{
public void onCreate(Bundle savedInstancestate) {
super.onCreate(savedInstancestate);
setContentView(R.layout.main2);
Button previous=(Button) findViewById(R.id.button_prev);
}
public void prevclickhandler(View view)
{
Intent intent=new Intent();
setResult(RESULT_OK,intent);
finish();
}
}
请建议我解决方案。