安卓折线图插件和自带截图分享的实现
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; } }
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28