当我在我的主类中添加构造函数时,由于下面的代码,它会给出错误。我能知道为什么吗?(没有构造函数它工作正常。)
public class AndroidGPSTrackingActivity extends Activity implements OnClickListener{
Button btnShowLocation ;
private final Context mContext;
public AndroidGPSTrackingActivity(Context context) {
this.mContext = context.getApplicationContext();
//tpMethod();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("Main", "class");
btnShowLocation = (Button) findViewById(R.id.btnShowLocation);
// show location button click event
btnShowLocation.setOnClickListener(this);
}
}
错误:java.lang.RuntimeException:无法实例化活动 ComponentInfo
java.lang.InstantiationException