package com.jiuqi.njt.receiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.jiuqi.njt.data.OptsharepreInterface;
import com.jiuqi.njt.util.UIUtil;
/**
*
* Description: 用来启动其他应用程序的广播接口
* ClassName: ComponentReceiver
*/
public class ActivityStartIntentReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
try{
ComponentName componentName =
new ComponentName(intent.getStringExtra("packageName"),intent.getStringExtra("pac_acvity"));
intent.setComponent(componentName);
Bundle bundle = new Bundle();
bundle.putString("name", new OptsharepreInterface(context).getPres("account"));
bundle.putString("pwd", new OptsharepreInterface(context).getPres("password"));
intent.putExtras(bundle);
//利用context来开启activity时候一定要加上下面这句。
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.getApplicationContext().startActivity(intent);
}
catch(Exception e){
UIUtil.showMsg(context, "对不起,启动应用程序时出现异常,请与我们联系!");
e.printStackTrace();
}
}
}