我的应用程序在我的离线壁纸应用程序中崩溃了。 我在LogCat中收到的消息是:
com.google.android.apps.gsa.shared.exception.GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间
请帮忙吗?
其离线应用,因此它不会使用互联网访问壁纸。
MainActivity
package com.jimdo.saifstudios.miniwallpack;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button bt_image1, bt_image2, bt_image3, bt_image4, bt_image5, bt_image6,
bt_image7, bt_image8,
bt_image9, bt_image10, bt_image11, bt_image12, bt_image13,
bt_image14, bt_image15,
bt_image16;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt_image1 = (Button) findViewById(R.id.bt_image1);
bt_image2 = (Button) findViewById(R.id.bt_image2);
bt_image3 = (Button) findViewById(R.id.bt_image3);
bt_image4 = (Button) findViewById(R.id.bt_image4);
bt_image5 = (Button) findViewById(R.id.bt_image5);
bt_image6 = (Button) findViewById(R.id.bt_image6);
bt_image7 = (Button) findViewById(R.id.bt_image7);
bt_image8 = (Button) findViewById(R.id.bt_image8);
bt_image9 = (Button) findViewById(R.id.bt_image9);
bt_image10 = (Button) findViewById(R.id.bt_image10);
bt_image11 = (Button) findViewById(R.id.bt_image11);
bt_image12 = (Button) findViewById(R.id.bt_image12);
bt_image13 = (Button) findViewById(R.id.bt_image13);
bt_image14 = (Button) findViewById(R.id.bt_image14);
bt_image15 = (Button) findViewById(R.id.bt_image15);
bt_image16 = (Button) findViewById(R.id.bt_image16);
bt_image1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "camelb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//2
bt_image2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "mib";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//3
bt_image3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "lighthouseb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//4
bt_image4.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "deerb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//5
bt_image5.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "nightb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//6
bt_image6.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "deertob";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//7
bt_image7.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "mountainb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//8
bt_image8.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "nightseab";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//9
bt_image9.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "snowfallb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//10
bt_image10.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "spaceb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//11
bt_image11.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "sunnyb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//12
bt_image12.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "sunnyseab";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//13
bt_image13.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "villageb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//14
bt_image14.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "desertb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//15
bt_image15.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "nightmoonb";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
//16
bt_image16.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,ThemeActivity.class);
String pathPic = "lighthouseseab";
i.putExtra("PATH_PICTURE", pathPic);
startActivity(i);
}
});
}
}
ThemeActivity
package com.jimdo.saifstudios.miniwallpack;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
public class ThemeActivity extends AppCompatActivity {
RelativeLayout theme_preview;
Button back_btn, save_btn;
String newString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_theme);
theme_preview = (RelativeLayout) findViewById(R.id.theme_preview);
save_btn = (Button) findViewById(R.id.save_btn);
back_btn = (Button) findViewById(R.id.back_btn);
if(savedInstanceState == null) {
Bundle extras = getIntent().getExtras();
if(extras == null) {
newString = null;
} else {
newString = extras.getString("PATH_PICTURE");
if(newString.equals("camelb")) {
theme_preview.setBackgroundResource(R.drawable.camelb);
} else if(newString.equals("mib2")) {
theme_preview.setBackgroundResource(R.drawable.mib);
} else {
//write the statement.
}
}
}
back_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
onBackPressed();
}
});
}
}
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jimdo.saifstudios.miniwallpack">
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ThemeActivity"></activity>
</application>
</manifest>