zoukankan      html  css  js  c++  java
  • android的一些特殊玩法

    1.让一个图片透明:

    复制到剪贴板 Java代码

    1. Bitmap buffer = Bitmap.createBitmap(width, border="1" Height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);

    2.直接发送邮件:

    复制到剪贴板 Java代码

    1. Intent intent = new Intent(Intent.ACTION_SENDTO, Uri .fromParts( "mailto" , "test@test.com" , null ));

    2. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    3. context.startActivity(intent);

    3.程序控制屏幕变亮:

    复制到剪贴板 Java代码

    1. WindowManager.LayoutParams lp = getWindow().getAttributes();

    2. lp.screenBrightness = 100 / 100 .0f;

    3. getWindow().setAttributes(lp);

    4.过滤特定文本

    复制到剪贴板 Java代码

    1. Filter filter = myAdapter.getFilter();

    2. filter.filter(mySearchText);

    5.scrollView scroll停止事件

    复制到剪贴板 Java代码

    1. setOnScrollListener( new OnScrollListener(){

    2. public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    3. // TODO Auto-generated method stub }

    4. public void onScrollStateChanged(AbsListView view, int scrollState) {

    5. // TODO Auto-generated method stub

    6. if (scrollState == 0 ) Log.i( "a" , "scrolling stopped..." ); } });}

    6. 对于特定的程序 发起一个关联供打开

    复制到剪贴板 C/C++代码

    1. Bitmap bmp = getImageBitmap(jpg);

    2. String path = getFilesDir().getAbsolutePath() + "/test.png" ;

    3. File file = new File(path);

    4. FileOutputStream fos = new FileOutputStream(file);

    5. bmp.compress( CompressFormat.PNG, 100, fos );

    6. fos.close();

    7.

    8. Intent intent = new Intent();

    9. intent.setAction(android .content.Intent.ACTION_VIEW);

    10. intent.setDataAndType(Uri .fromFile( new File(path)), "image/png"

    *byte转化为Bitmap,防止内存溢出
    Java代码
       
    ByteArrayInputStream is =new ByteArrayInputStream(byte[]);     
    BitmapFactory.Options options=new BitmapFactory.Options();      
    options.inPurgeable = true;     
    options.inInputShareable = true;     
    options.inSampleSize = 2;     
    try {     
        BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options,true);     
    } catch(Exception ex) {     
        ex.printStackTrace();     
    }     
    Bitmap imgBit = (new WeakReference<Bitmap>(BitmapFactory.decodeStream(is, null, options))).get(); 

  • 相关阅读:
    glog Windows Visual Studio 2013 编译项目
    Git Tag管理发行版本
    Ubuntu 16.04环境中读取XBOX 360手柄信息
    GCC 中 的pie和fpie选项
    CMakeLists.txt 常用指令说用
    chrome无法访问github.com
    删除前n天的数据
    shell(9)秒转换为时分秒
    Drools规则引擎实践直白总结
    空闲时间研究一个小功能:winform桌面程序如何实现动态更换桌面图标
  • 原文地址:https://www.cnblogs.com/crazywenza/p/2793030.html
Copyright © 2011-2022 走看看