Android tabhost groupactivity不工作(已弃用) 公共类反馈扩展了ActivityGroup{ 受保护的静态本地活动管理器mLocalActivityManager; 私有EditText fd=null; 私有按钮发送=空; 公共int res_标志=0; 公共字符串结果=”; 公共字符串url=“”; 私人亲戚账户; 私有文本视图needhelp=null; 私有字符串currentDateandTime=“”; 私有布尔等值线; 受保护字符串fd_text=“”; public void replaceContentView(字符串id,Intent newIntent){ 视图视图=getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();this.setContentView(视图); } @凌驾 创建时受保护的void(Bundle savedInstanceState){ //TODO自动生成的方法存根 super.onCreate(savedInstanceState); setContentView(R.layout.feedback); 初始化(); 试一试{ SimpleDataFormat sdf=新的SimpleDataFormat(“yyyy-MM-dd hh:MM:ss”); currentDateandTime=sdf.format(新日期()); }捕获(例外e){ 系统输出打印ln(e); } send.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ 新建反馈。检索()。执行(); } }); } 私有void初始化() { fd=(EditText)findViewById(R.id.fd); send=(按钮)findviewbyd(R.id.send); } 类检索扩展异步任务{ ProgressDialog pd=null; @凌驾 受保护的void onPreExecute(){ //TODO自动生成的方法存根 super.onPreExecute(); pd=新进度对话框(反馈。此); pd.setMessage(“发送反馈时请稍候…”); pd.可设置可取消(假); pd.show(); } @凌驾 受保护的整数doInBackground(Void…params){ 试试{ System.out.println(“IN-BKGRND”); StrictMode.ThreadPolicy policy1=新StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(策略1); url=“url”+fd_text.toString().trim()+”&datetime=“+currentDateandTime; url=url.replace(“,“%20”); url=url.replace(“+”,“%2B”); System.out.println(url); JSONObject json=JSONfunctions.getJSONfromURL(url); JSONObject response1=json.getJSONObject(“响应”); 结果=response1.getString(“成功”).toString().trim(); 系统输出打印项次(结果); if(结果等信号情况(“1”)) { System.out.println(“登录”); res_flag=1; } 其他的 { System.out.println(“失败”); res_标志=5; } } 捕获(JSONException e){ 系统输出打印ln(e); }捕获(例外e){ 系统输出打印ln(e); } 返回null; } @凌驾 受保护的void onPostExecute(整数结果){ super.onPostExecute(结果); pd.解散();
} 错误为: android.view.WindowManager$BadTokenException:无法添加窗口--标记android.app.LocalActivityManager$LocalActivityRecord@40e16110无效;您的活动正在运行吗 问题 我通过另一个tabhost调用活动。它只加载视图。Web服务和按钮不工作。当我单击按钮时,它显示上面的错误。请帮助我继续 参考资料:Android tabhost groupactivity不工作(已弃用) 公共类反馈扩展了ActivityGroup{ 受保护的静态本地活动管理器mLocalActivityManager; 私有EditText fd=null; 私有按钮发送=空; 公共int res_标志=0; 公共字符串结果=”; 公共字符串url=“”; 私人亲戚账户; 私有文本视图needhelp=null; 私有字符串currentDateandTime=“”; 私有布尔等值线; 受保护字符串fd_text=“”; public void replaceContentView(字符串id,Intent newIntent){ 视图视图=getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();this.setContentView(视图); } @凌驾 创建时受保护的void(Bundle savedInstanceState){ //TODO自动生成的方法存根 super.onCreate(savedInstanceState); setContentView(R.layout.feedback); 初始化(); 试一试{ SimpleDataFormat sdf=新的SimpleDataFormat(“yyyy-MM-dd hh:MM:ss”); currentDateandTime=sdf.format(新日期()); }捕获(例外e){ 系统输出打印ln(e); } send.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ 新建反馈。检索()。执行(); } }); } 私有void初始化() { fd=(EditText)findViewById(R.id.fd); send=(按钮)findviewbyd(R.id.send); } 类检索扩展异步任务{ ProgressDialog pd=null; @凌驾 受保护的void onPreExecute(){ //TODO自动生成的方法存根 super.onPreExecute(); pd=新进度对话框(反馈。此); pd.setMessage(“发送反馈时请稍候…”); pd.可设置可取消(假); pd.show(); } @凌驾 受保护的整数doInBackground(Void…params){ 试试{ System.out.println(“IN-BKGRND”); StrictMode.ThreadPolicy policy1=新StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(策略1); url=“url”+fd_text.toString().trim()+”&datetime=“+currentDateandTime; url=url.replace(“,“%20”); url=url.replace(“+”,“%2B”); System.out.println(url); JSONObject json=JSONfunctions.getJSONfromURL(url); JSONObject response1=json.getJSONObject(“响应”); 结果=response1.getString(“成功”).toString().trim(); 系统输出打印项次(结果); if(结果等信号情况(“1”)) { System.out.println(“登录”); res_flag=1; } 其他的 { System.out.println(“失败”); res_标志=5; } } 捕获(JSONException e){ 系统输出打印ln(e); }捕获(例外e){ 系统输出打印ln(e); } 返回null; } @凌驾 受保护的void onPostExecute(整数结果){ super.onPostExecute(结果); pd.解散();,android,android-tabhost,Android,Android Tabhost,} 错误为: android.view.WindowManager$BadTokenException:无法添加窗口--标记android.app.LocalActivityManager$LocalActivityRecord@40e16110无效;您的活动正在运行吗 问题 我通过另一个tabhost调用活动。它只加载视图。Web服务和按钮不工作。当我单击按钮时,它显示上面的错误。请帮助我继续 参考资料: 现在ActivityGroup已被弃用..,我现在应该使用什么..对于您发布的内容,您
现在ActivityGroup已被弃用..,我现在应该使用什么..对于您发布的内容,您似乎根本不需要使用
ActivityGroup
。只需从Activity
类扩展您的反馈
。例如:
public class Feedback extends ActivityGroup {
protected static LocalActivityManager mLocalActivityManager;
private EditText fd=null;
private Button send=null;
public int res_flag=0;
public String result="";
public String url="";
private RelativeLayout newaccount;
private TextView needhelp=null;
private String currentDateandTime="";
private boolean isonline;
protected String fd_text="";
public void replaceContentView(String id, Intent newIntent) {
View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); this.setContentView(view);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.feedback);
initialization();
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
currentDateandTime = sdf.format(new Date());
}catch (Exception e) {
System.out.println(e);
}
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Feedback.Retrieve().execute();
}
});
}
private void initialization()
{
fd=(EditText)findViewById(R.id.fd);
send=(Button)findViewById(R.id.send);
}
class Retrieve extends AsyncTask<Void, Integer, Integer> {
ProgressDialog pd = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pd = new ProgressDialog(Feedback.this);
pd.setMessage("Please wait while sending feedback..");
pd.setCancelable(false);
pd.show();
}
@Override
protected Integer doInBackground(Void... params) {
try{
System.out.println("IN BKGRND");
StrictMode.ThreadPolicy policy1 = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy1);
url="url"+fd_text.toString().trim()+"&datetime="+currentDateandTime;
url=url.replace(" ","%20");
url=url.replace("+","%2B");
System.out.println(url);
JSONObject json = JSONfunctions.getJSONfromURL(url);
JSONObject response1=json.getJSONObject("response");
result=response1.getString("Success").toString().trim();
System.out.println(result);
if(result.equalsIgnoreCase("1"))
{
System.out.println("Logged In");
res_flag=1;
}
else
{
System.out.println("failed");
res_flag=5;
}
}
catch (JSONException e) {
System.out.println(e);
}catch (Exception e) {
System.out.println(e);
}
return null;
}
@Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
pd.dismiss();
我在另一个类文件中有一个TabActivity..当我单击一个页面时,它不应该从tabhost中出来..为此我编写了GroupActivity..参考如我所说,您发布的代码不能证明需要使用ActivityGroup。请将其替换为Activity,然后看看它是如何运行的。View View=getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();this.setContentView(view);虽然我也更改了该活动,但上面一行不接受getLocalActivityManager()。。
public class Feedback extends Activity