欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

安卓折线图插件和自带截图分享的实现

程序员文章站 2022-07-09 09:27:36
...



package com.example.test;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Surface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;

public class MainActivity extends Activity {
	
	 private Matrix mDisplayMatrix;  
	 private Display mDisplay;  
     private DisplayMetrics mDisplayMetrics;  
     private Bitmap mScreenBitmap;  
     private WindowManager mWindowManager; 
	 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_main);
		//  
			setContentView(R.layout.activity_main); 
	        WebView wView = (WebView)findViewById(R.id.webview); 
	        Button btn_fen=(Button)findViewById(R.id.btn_fen);   
	        
	        WebSettings wSet = wView.getSettings();     
	        //wSet.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
	        wSet.setUseWideViewPort(true);
	        wSet.setLoadWithOverviewMode(true);
	        String data="55,33,86,57,99,14,25,36,44,58,78,69";
	        wSet.setJavaScriptEnabled(true);   
	        wView.loadUrl("file:///android_asset/line2d_06.html?"+data);  
//	        
	        btn_fen.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					        File file_save_pic=new File(Environment.getExternalStorageDirectory().getPath() +"/sharetmp.jpg");
					        
					        ScreenShot.shoot(MainActivity.this, file_save_pic);
					
							Intent 	shareInt=new Intent(Intent.ACTION_SEND);
//							shareInt.setType("text/plain");   
							shareInt.setType("image/png");
							shareInt.putExtra(Intent.EXTRA_SUBJECT, "选择分享方式");   
							//shareInt.putExtra(Intent.EXTRA_TEXT, "kkkkkkkkkkkkkkkkkkkkkkk");  
							shareInt.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file_save_pic));  
							shareInt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
							startActivity(shareInt);
				 }  
			});
	}
	 /** 
     * @return the current display rotation in degrees 
     */  
    private float getDegreesForRotation(int value) {  
        switch (value) {  
        case Surface.ROTATION_90:  
            return 360f - 90f;  
        case Surface.ROTATION_180:  
            return 360f - 180f;  
        case Surface.ROTATION_270:  
            return 360f - 270f;  
        }  
        return 0f;  
    }  


}

 

源码下载地址 :http://www.32666.com/file-553531.html

 

 

  • 安卓折线图插件和自带截图分享的实现
            
    
    博客分类: Android java360Palmandroid截图 
  • 大小: 38.7 KB
  • 安卓折线图插件和自带截图分享的实现
            
    
    博客分类: Android java360Palmandroid截图 
  • 大小: 47.8 KB