0
点赞
收藏
分享

微信扫一扫

android琐碎笔记六


1.得到屏幕的screen dimensions
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();int height = display.getHeight();

2. 播放 gif图片在android

@Override protected void onDraw(Canvas canvas) { 

 canvas.drawColor(0xFFCCCCCC); 

 Paint p = new Paint(); 

 p.setAntiAlias(true); 


 canvas.drawBitmap(mBitmap4, 210, 170, null); 

 mDrawable.draw(canvas); 

 long now = android.os.SystemClock.uptimeMillis(); 

 if (mMovieStart == 0) { // first time mMovieStart = now; } 

 if (mMovie != null) { 

 int dur = mMovie.duration(); 

 if (dur == 0) { 

 dur = 1000; } 

 int relTime = (int)((now - mMovieStart) % dur); 

 mMovie.setTime(relTime); 

 mMovie.draw(canvas, getWidth() - mMovie.width(), 

 getHeight() - mMovie.height()); 

 invalidate(); 

 } 

 }


http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.html @Override

protected void onDraw(Canvas canvas) { 

 if(movie != null) { 

 long now = android.os.SystemClock.uptimeMillis(); 

 int dur = Math.max(movie.duration(), 1); 

 // is it really animated? 

 int pos = (int)(now % dur); 

 movie.setTime(pos); 

 movie.draw(canvas, x, y); 

 invalidate(); 

 }}



4. 打开sd卡中的sqllite
File dbfile = new File("/sdcard/mydb.sqlite" );
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);

5.得到手机的IMEI
((TelephonyManager) getSystemService=(Context.TELEPHONY_SERVICE)).getDeviceId();

6. 不让程序 生成一个appliation 去掉
<category android:name="android.intent.category.LAUNCHER" />
当然你的让你的程序 被引导启动

7.使用appliation 的id 可以获得不同appliation的数据:
android:sharedUserId="string" 在主xml中添加上面一句话,然后签名也要一样 两个app的id也要设置成一样 如都是string 那么这两个程序就可以相互访问彼此的数据,也可以在同一个process中了
8.判断相机设备存在不
private android.hardware.Camera mCameraDevice;
try {
mCameraDevice = android.hardware.Camera.open();}
catch (RuntimeException e) { Log.e(TAG, "fail to connect Camera", e);

9使listView 透明
android:background="#00000000"
android:cacheColorHint="#00000000"
或者
android:background="@android:color/transparent"

•The background android screen image should be visible.
屏幕的背景图像可以看见
manifest file 添加attribute 到 activity.
android:theme="@android:style/Theme.Dialog"

举报

相关推荐

0 条评论