![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Android snippets
CrossTime
helloworld
展开
-
取得当前屏幕方向&大小
<br />如何取得屏幕的方向:<br />if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.i("info", "landscape"); } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT原创 2011-04-23 13:14:00 · 686 阅读 · 0 评论 -
Bitmap, Drawable, Byte之间的转化
1. Bitmap 转化为 byteByteArrayOutputStream out = new ByteArrayOutputStream();bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); //bitmap.compress(Bitmap.CompressFormat.JPEG, 85, stream);byte[] array= out.toByteArray();2. byte转化为bitmap『byte[] data』Bitmap转载 2011-04-23 13:19:00 · 915 阅读 · 0 评论 -
改变dialog的位置
<br />改变位置:<br /> WindowManager.LayoutParams lp = myDialog.getAttributes();<br /> lp.x = newXoffset;<br /> lp.y = newYoffset;<br /> myDialog.setAttributes(lp);<br />对话框缺省lp.x=0,lp.y=0, 在居中位置<br /> x<0左移,x>0右移<br /> y<0上移原创 2011-04-23 13:50:00 · 467 阅读 · 0 评论 -
Locale,auto-rotate状态的获取
<br /> <br />1. 得到当前locale:<br /><br />Context.getResources().getConfiguration.locale;<br /> <br /> <br />2. 是否开启了auto-rotate:(这个和具体设备似乎也有关系,不确定是否通用)<br /> <br />import android.provider.Settings; <br />mAutoRotateSwitch = (Settings.System.getInt(this.getCo原创 2011-04-23 13:59:00 · 564 阅读 · 0 评论 -
得到能打开指定类型文件的应用程序列表
<br />Intent it = new Intent(); it.setType("image/*") List<ResolveInfo> ra = this.getPackageManager().queryIntentActivities(it,0); for(int i=0;i<ra.size();i++){ ActivityInfo ai = ra.get(i).activityInfo; Drawable icon = ai.loadIcon(this.转载 2011-04-23 14:14:00 · 758 阅读 · 0 评论