在我的项目中,我添加了一项新功能,例如分享我应用的快照。在我的设备中运行我的项目时,该功能在点击我的Button
时不起作用它没有做任何事情只是它显示 Logcat ,如下所示:
我怎么能解决它.. ???
提前谢谢
08-04 16:08:33.059 32052-32062/com.sentientit.theiWedplanner W/art﹕ Suspending all threads took: 6.343ms
08-04 16:08:33.115 32052-32062/com.sentientit.theiWedplanner W/art﹕ Suspending all threads took: 49.947ms
08-04 16:08:33.122 32052-32067/com.sentientit.theiWedplanner I/art﹕ Background sticky concurrent mark sweep GC freed 146699(10MB) AllocSpace objects, 57(1824KB) LOS objects, 18% free, 34MB/42MB, paused 1.590ms total 279.950ms
08-04 16:08:33.139 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
08-04 16:08:33.772 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 32 frames! The application may be doing too much work on its main thread.
08-04 16:08:36.134 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 34 frames! The application may be doing too much work on its main thread.
08-04 16:08:41.027 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:41.842 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:42.564 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:43.788 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:44.504 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 42 frames! The application may be doing too much work on its main thread.
08-04 16:08:46.948 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 48 frames! The application may be doing too much work on its main thread.
08-04 16:08:51.777 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 44 frames! The application may be doing too much work on its main thread.
08-04 16:08:52.490 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:53.209 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:08:54.572 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 45 frames! The application may be doing too much work on its main thread.
08-04 16:08:55.359 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 47 frames! The application may be doing too much work on its main thread.
08-04 16:08:57.612 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 39 frames! The application may be doing too much work on its main thread.
08-04 16:09:02.531 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 44 frames! The application may be doing too much work on its main thread.
08-04 16:09:03.243 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 41 frames! The application may be doing too much work on its main thread.
08-04 16:09:04.075 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 48 frames! The application may be doing too much work on its main thread.
08-04 16:09:05.189 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 36 frames! The application may be doing too much work on its main thread.
08-04 16:09:06.110 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 44 frames! The application may be doing too much work on its main thread.
08-04 16:09:08.265 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:13.177 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:13.996 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 45 frames! The application may be doing too much work on its main thread.
08-04 16:09:14.107 32052-32067/com.sentientit.theiWedplanner I/art﹕ Background sticky concurrent mark sweep GC freed 92885(6MB) AllocSpace objects, 23(368KB) LOS objects, 16% free, 35MB/42MB, paused 1.240ms total 111.681ms
08-04 16:09:14.718 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:15.847 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 39 frames! The application may be doing too much work on its main thread.
08-04 16:09:16.762 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:18.912 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:23.825 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:24.646 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:25.363 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
08-04 16:09:26.516 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 40 frames! The application may be doing too much work on its main thread.
08-04 16:09:27.521 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 44 frames! The application may be doing too much work on its main thread.
08-04 16:09:29.563 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:34.486 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 39 frames! The application may be doing too much work on its main thread.
08-04 16:09:35.397 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 44 frames! The application may be doing too much work on its main thread.
08-04 16:09:36.215 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 48 frames! The application may be doing too much work on its main thread.
08-04 16:09:37.349 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 49 frames! The application may be doing too much work on its main thread.
08-04 16:09:38.168 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
08-04 16:09:40.415 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 50 frames! The application may be doing too much work on its main thread.
08-04 16:09:45.124 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
08-04 16:09:46.050 32052-32052/com.sentientit.theiWedplanner I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
这是我的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/aagr_background2"
android:orientation="vertical" >
<fragment
android:id="@+id/adview153613"
android:name="com.sentientit.theiWedplanner.Fragadmob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
tools:layout="@layout/fragadmob" />
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/aanavigationbar">
<Button
android:id="@+id/back"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="3dp"
android:layout_x="8px"
android:layout_y="3px"
android:background="@drawable/custom_btn_breaker_bay"
android:text="Back"
android:textColor="#ffffff"
android:textSize="20sp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="437dp"
android:layout_y="3dp"
android:src="@drawable/add11_table"
android:layout_alignBottom="@+id/back"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:id="@+id/home"
android:layout_width="50px"
android:layout_height="30px"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/back"
android:layout_marginRight="46dp"
android:background="@drawable/home1"
android:paddingBottom="12px"
android:paddingTop="10px"
android:visibility="gone" />
<Button
android:id="@+id/share"
android:background="@drawable/share"
android:layout_width="50dp"
android:layout_height="49dp"
android:layout_below="@+id/home"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="30dp"
android:id="@+id/imageView"
android:layout_gravity="center_horizontal"
android:layout_weight="0.11"
android:background="@drawable/stag"
android:layout_marginTop="1dp"
android:layout_marginBottom="2dp"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.91"
android:orientation="vertical"
>
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
<AbsoluteLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.1"
android:layout_gravity="center">
<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="4dp"
android:text="Line"
android:textSize="20sp" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_x="128dp"
android:layout_y="4dp"
android:text="circle"
android:textSize="20sp" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="212dp"
android:layout_y="4dp"
android:text="vshape"
android:textSize="20sp" />
</AbsoluteLayout>
</LinearLayout>
这是按钮的代码
public class Engagement_Tableviewtable extends FragmentActivity
{
Bitmap myBitmap;
Button button;
@Override
public void onStart() {
super.onStart();
// The rest of your onStart() code.
// // EasyTracker.getInstance(this).activityStart(this); // Add this method.
}
@Override
public void onStop() {
super.onStop();
// The rest of your onStop() code.
// EasyTracker.getInstance(this).activityStop(this); // Add this method.
}
ImageButton tshape;
int totadlcnt = 0;
LinearLayout layout1;
LinearLayout table;
LinearLayout mylayout;
int status;
String tablecnt= null;
String username=LoginForm.str1;
private String result = null;
StringTokenizer2 token = null, token1 = null,token2 =null;
ArrayList<String> value = new ArrayList<String>();
ArrayList<String> value1 = new ArrayList<String>();
ArrayList<String> str = new ArrayList<String>();
ArrayList<String> totseat=null;
ArrayList<String> shape = null;
ArrayList<String> tblcount = null;
ArrayList<String> totadltseats = null;
ArrayList<String> adultcnt = null;
ArrayList<String> totkidseats = null;
ArrayList<String> kidcnt = null;
ArrayList<String> tottno = new ArrayList<String>();
ArrayList<String> clo = new ArrayList<String>();
ScrollView scroll;
static int NO_OF_ROWS =5;
String occation = SeatingArrangement.funName;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(this, "68640bea");
setContentView(R.layout.seat);
Button back = (Button)findViewById(R.id.back);
Button home = (Button) findViewById(R.id.home);
button = (Button) findViewById(R.id.share);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
button();
}
});
public void saveBitmap(Bitmap bitmap) {
String filePath = Environment.getExternalStorageDirectory()
+ File.separator + "Pictures/screenshot.png";
File imagePath = new File(filePath);
FileOutputStream fos;
try {
fos = new FileOutputStream(imagePath);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
sendMail(filePath);
} catch (FileNotFoundException e) {
Log.e("GREC", e.getMessage(), e);
} catch (IOException e) {
Log.e("GREC", e.getMessage(), e);
}
}
public void sendMail(String path) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/png");
Uri myUri = Uri.parse("file://" + path);
emailIntent.putExtra(Intent.EXTRA_STREAM, myUri);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
private boolean button() {
final FrameLayout iv = (FrameLayout) findViewById(R.id.vg);
View v1 = getWindow().getDecorView().getRootView();
// View v1 = iv.getRootView(); //even this works
// View v1 = findViewById(android.R.id.content); //this works too
// but gives only content
v1.setDrawingCacheEnabled(true);
myBitmap = v1.getDrawingCache();
saveBitmap(myBitmap);
return false;
}
答案 0 :(得分:1)
试试这个。
在单独的帖子中写saveBitmap()
。
Thread tr = new Thread(){
run(){
saveBitmap();
}
}
tr.start();
我认为,你用主线加载太多东西的问题。
我猜按钮点击是,
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button();
}
});
也检查一下。