我已经为我的android Activity类添加了一些本机方法.现在我想为它创建头文件class.
从命令行创建头文件时出现以下错误.
C:\AndroidProjects\JniTest\bin\classes>javah -classpath .;
C:\adt-bundle-windows-x86\sdk\platforms\android.jar com.example.jnitest.JniTest
Error: cannot access android.app.Activity
class file for android.app.Activity not found
Run Code Online (Sandbox Code Playgroud)
基本上无法从jar访问活动类.
请指教.
java java-native-interface android android-ndk android-activity
可能重复:
活动上下文和应用程序上下文之间的差异
何时使用Context和Activity.我已经阅读了使用Context和Activity作为参数的代码,如下面的构造函数,请在此清除我
public AmazedView(Context context, Activity activity) {
super(context);
mActivity = activity;
// init paint and make is look "nice" with anti-aliasing.
mPaint = new Paint();
mPaint.setTextSize(14);
mPaint.setTypeface(mFont);
mPaint.setAntiAlias(true);
// setup accelerometer sensor manager.
mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
// register our accelerometer so we can receive values.
// SENSOR_DELAY_GAME is the recommended rate for games
mSensorManager.registerListener(mSensorAccelerometer, SensorManager.SENSOR_ACCELEROMETER,
SensorManager.SENSOR_DELAY_GAME);
// setup our maze and marble.
mMaze = new Maze(mActivity);
mMarble = new Marble(this);
// load array from /res/values/strings.xml
mStrings = …Run Code Online (Sandbox Code Playgroud) 我在15天前在Google Play上发布了一个应用程序,我对该应用程序进行了一些修改,现在我想再次发布它.
当我尝试在不更改VersionCode ="1"的情况下上传apk时,Google Developers Console给了我一个错误:已经存在versionCode ="1"的应用程序.
然后我尝试将版本代码更改为2并导出apk,遗憾的是,VersionCode始终会恢复为"1".
请帮忙解决这个问题.
我正在尝试创建一个自定义编辑文本,并在这里陷入困境......
请参阅下面的代码
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public static class MyEditText1 extends EditText{
Paint mPaint;
public MyEditText1(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MyEditText1(Context context, AttributeSet attrs) {
super(context, attrs);
mPaint=new Paint();
mPaint.setColor(Color.BLACK);
}
@Override
protected void onDraw(Canvas c){
super.onDraw(c);
int height=getHeight();
int width=getWidth();
int linespace=10;
int count=height/linespace;
for(int i=0;i<count;i++){
c.drawLine(0, i*linespace, width, i*linespace, mPaint); …Run Code Online (Sandbox Code Playgroud) 从设置线程状态的角度来看,我不清楚这两种方法.
Java Docs说Thread.interrupt()设置线程中断状态标志并调用Thread.interrupted()方法给出线程的状态并清除标志.
当这在真实场景中使用时.. ??