当我在一段时间后启动我的应用程序时它会出错并且应用程序开始出错而且有一些相关的主题但我无法修复我的错误请帮助我
我的java代码;
package com.infotek.fusionlauncher;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.Toast;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
PopupWindow popUp;
boolean click = true;
Button tvbutton;
Button filmbutton;
Button facebookbutton;
Button browserbtn;
Button oyunbutton;
Button oisbutton;
// Button aihbutton;
Button uyebutton;
// Button settingsbutton;
Button twitterbutton;
Button contactbutton;
// Progress Dialog
private ProgressDialog pDialog;
private Socket socket;
private String serverIpAddress = "127.0.0.1";
// AND THAT'S MY DEV'T MACHINE WHERE PACKETS TO
// PORT 5000 GET REDIRECTED TO THE SERVER EMULATOR'S
// PORT 6000
private static final int REDIRECTED_SERVERPORT = 6000;
ImageView my_image;
// Progress dialog type (0 - for Horizontal progress bar)
public static final int progress_bar_type = 0;
// File url to download
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tvbutton=(Button) findViewById(R.id.tvbutton);
filmbutton=(Button) findViewById(R.id.filmbutton);
facebookbutton=(Button) findViewById(R.id.facebookbutton);
twitterbutton=(Button) findViewById(R.id.twitterbutton);
// settingsbutton = (Button) findViewById(R.id.settingsbutton);
browserbtn=(Button) findViewById(R.id.buttonbrowser);
oyunbutton=(Button) findViewById(R.id.oyunbutton);
oisbutton=(Button) findViewById(R.id.oisbutton);
// aihbutton=(Button) findViewById(R.id.aihbutton);
uyebutton=(Button) findViewById(R.id.uyebutton);
contactbutton =(Button) findViewById(R.id.contactbutton);
/*final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Toast.makeText(getApplicationContext(), packageInfo.packageName, Toast.LENGTH_LONG).show();
//Log.d(TAG, "Installed package :" + packageInfo.packageName);
//Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));
}*/
System.runFinalization();
Runtime.getRuntime().gc();
System.gc();
File file = getBaseContext().getFileStreamPath("language");
if(!file.exists()){
languagefile("tr");
}
else{
//dildegistir(diloku());
}
try {
dosyakopyala("de_language.xml");
dosyakopyala("eng_language.xml");
dosyakopyala("ru_language.xml");
dosyakopyala("tr_language.xml");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// settingsbutton.setOnClickListener(new OnClickListener() {
// public void onClick(View v) {
// dilpenceresi();
// }
// });
tvbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.infotek.hdtv"));
//startActivity(getPackageManager().getLaunchIntentForPackage("net.innodigital.inettvplayer"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
filmbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.infotek.hdfilms"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
facebookbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.facebook"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
twitterbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.twitter.android"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
oyunbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.oyun"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
contactbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.infotek.form"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
oisbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.news"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
browserbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
startActivity(getPackageManager().getLaunchIntentForPackage("com.browser"));
} catch (Exception e) {
Log.d("attention", "Activity baslatma basarisiz");
}
}
});
}
public void languagefile(String dil){
String fileName = "language";
String content = dil;
FileOutputStream fos;
try {
fos = openFileOutput(fileName, Context.MODE_WORLD_READABLE);
fos.write(content.getBytes());
fos.close();
//Toast.makeText( getApplicationContext(),fileName + " saved",Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressLint("WorldReadableFiles")
public void dosyakopyala(String dosya) throws IOException {
System.runFinalization();
Runtime.getRuntime().gc();
System.gc();
InputStream myInput = getApplicationContext().getAssets().open(dosya);
File dir = getFilesDir();
File file = new File(dir, dosya);
boolean deleted = file.delete();
if(file.exists())
file.delete();
//Open the empty db as the output stream
FileOutputStream fos = openFileOutput(dosya, Context.MODE_WORLD_READABLE);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
fos.write(buffer, 0, length);
}
//Close the streams
fos.flush();
fos.close();
myInput.close();
}
public String diloku(){
int ch;
String fileName = "language";
StringBuffer fileContent = new StringBuffer("");
FileInputStream fis;
try {
fis = openFileInput( fileName );
try {
while( (ch = fis.read()) != -1)
fileContent.append((char)ch);
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String data = new String(fileContent);
return data;
}
public void onBackPressed() { // do nothing.
}
public void xmloku(){
String gelenurl = "http://www.fusionstech.com/fusionupdate.xml";
try {
URL url = new URL(gelenurl);
DocumentBuilderFactory dFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
Document document = dBuilder
.parse(new InputSource(url.openStream()));
document.getDocumentElement().normalize();
//Url den gelen xml dškŸmanİ Stream olußturup dškŸmana parse ettik.
NodeList forecast_information = document
.getElementsByTagName("fusion");
for (int i = 0; i < forecast_information.getLength(); i++) {
Node node = forecast_information.item(i);
Element elementMain = (Element) node;
String deger = elementMain.getAttribute("update");
new DownloadFileFromURL().execute(elementMain.getAttribute("apk"));
}} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Showing Dialog
* */
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case progress_bar_type: // we set this to 0
pDialog = new ProgressDialog(this);
pDialog.setMessage("Downloading file. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setMax(100);
pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pDialog.setCancelable(true);
pDialog.show();
return pDialog;
default:
return null;
}
}
public void someMethod(String someParam) {
// do something with string here
Toast.makeText(getApplicationContext(), String.valueOf(getFilesDir())+someParam, Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(getFilesDir() +"/"+ someParam)), "application/vnd.android.package-archive");
startActivity(intent);
}
/**
* Background Async Task to download file
* */
class DownloadFileFromURL extends AsyncTask<String, String, String> {
/**
* Before starting background thread
* Show Progress Bar Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
/**
* Downloading file in background thread
* */
@Override
protected String doInBackground(String... f_url) {
int count;
try {
URL url = new URL("http://www.fusionstech.com/"+f_url[0]);
URLConnection conection = url.openConnection();
conection.connect();
// this will be useful so that you can show a tipical 0-100% progress bar
int lenghtOfFile = conection.getContentLength();
// download the file
InputStream input = new BufferedInputStream(url.openStream(), 8192);
File myFile = new File(getFilesDir()+f_url[0]);
myFile.getCanonicalFile().delete();
// Output stream
OutputStream output = openFileOutput(f_url[0], Context.MODE_WORLD_READABLE);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
// After this onProgressUpdate will be called
publishProgress(""+(int)((total*100)/lenghtOfFile));
// writing data to file
output.write(data, 0, count);
}
// flushing output
output.flush();
// closing streams
output.close();
input.close();
} catch (Exception e) {
Log.e("Error: ", e.getMessage());
}
return f_url[0];
}
/**
* Updating progress bar
* */
protected void onProgressUpdate(String... progress) {
// setting progress percentage
pDialog.setProgress(Integer.parseInt(progress[0]));
}
/**
* After completing background task
* Dismiss the progress dialog
* **/
@Override
protected void onPostExecute(String file_url) {
// dismiss the dialog after the file was downloaded
dismissDialog(progress_bar_type);
someMethod(file_url);
//Intent intent = new Intent(Intent.ACTION_VIEW);
//intent.setDataAndType(Uri.fromFile(new File(getFilesDir() + file_url)), "application/vnd.android.package-archive");
//startActivity(intent);
}
}
}
我的布局;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="960px"
android:layout_height="540px"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/fusiontvbg1" />
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="65dp" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/tvbutton"
android:layout_width="141px"
android:layout_height="143px"
android:background="@drawable/tr_tvbutton" />
<Button
android:id="@+id/filmbutton"
android:layout_width="141px"
android:layout_height="143px"
android:background="@drawable/tr_filmbutton" />
<Button
android:id="@+id/oyunbutton"
android:layout_width="140px"
android:layout_height="143px"
android:background="@drawable/tr_oyunbutton" />
<Button
android:id="@+id/facebookbutton"
style="?android:attr/buttonStyleSmall"
android:layout_width="140px"
android:layout_height="143px"
android:background="@drawable/tr_facebookmain" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="144px"
android:layout_height="143px" >
<Button
android:id="@+id/uyebutton"
android:layout_width="142px"
android:layout_height="143px"
android:layout_margin="1dp"
android:background="@drawable/tr_uyepanelbutton" />
<Button
android:id="@+id/oisbutton"
android:layout_width="142px"
android:layout_height="143px"
android:background="@drawable/tr_oisbutton" />
<Button
android:id="@+id/contactbutton"
android:layout_width="140px"
android:layout_height="143px"
android:layout_margin="1dp"
android:background="@drawable/tr_contactbutton" />
<Button
android:id="@+id/twitterbutton"
style="?android:attr/buttonStyleSmall"
android:layout_width="140px"
android:layout_height="143px"
android:background="@drawable/twitter" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/buttonbrowser"
style="?android:attr/buttonStyleSmall"
android:layout_width="140px"
android:layout_height="290px"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/tableLayout1"
android:layout_marginRight="32dp"
android:layout_marginTop="2dp"
android:background="@drawable/internet" />
</RelativeLayout>
我的错误日志;
01-27 02:50:19.010: E/dalvikvm-heap(12204): 419888-byte external allocation too large for this process.
01-27 02:50:19.040: I/dalvikvm-heap(12204): Clamp target GC heap from 25.494MB to 24.000MB
01-27 02:50:19.040: E/GraphicsJNI(12204): VM won't let us allocate 419888 bytes
01-27 02:50:19.040: D/dalvikvm(12204): GC_FOR_MALLOC freed 0K, 53% free 2664K/5575K, external 18799K/20744K, paused 18ms
01-27 02:50:19.040: D/AndroidRuntime(12204): Shutting down VM
01-27 02:50:19.040: W/dalvikvm(12204): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-27 02:50:19.070: E/AndroidRuntime(12204): FATAL EXCEPTION: main
01-27 02:50:19.070: E/AndroidRuntime(12204): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infotek.fusionlauncher/com.infotek.fusionlauncher.MainActivity}: android.view.InflateException: Binary XML file line #40: Error inflating class <unknown>
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2796)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.access$1600(ActivityThread.java:117)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:932)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.os.Looper.loop(Looper.java:123)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.main(ActivityThread.java:3647)
01-27 02:50:19.070: E/AndroidRuntime(12204): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 02:50:19.070: E/AndroidRuntime(12204): at java.lang.reflect.Method.invoke(Method.java:507)
01-27 02:50:19.070: E/AndroidRuntime(12204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-27 02:50:19.070: E/AndroidRuntime(12204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-27 02:50:19.070: E/AndroidRuntime(12204): at dalvik.system.NativeStart.main(Native Method)
01-27 02:50:19.070: E/AndroidRuntime(12204): Caused by: android.view.InflateException: Binary XML file line #40: Error inflating class <unknown>
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-27 02:50:19.070: E/AndroidRuntime(12204): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-27 02:50:19.070: E/AndroidRuntime(12204): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.Activity.setContentView(Activity.java:1657)
01-27 02:50:19.070: E/AndroidRuntime(12204): at com.infotek.fusionlauncher.MainActivity.onCreate(MainActivity.java:95)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
01-27 02:50:19.070: E/AndroidRuntime(12204): ... 12 more
01-27 02:50:19.070: E/AndroidRuntime(12204): Caused by: java.lang.reflect.InvocationTargetException
01-27 02:50:19.070: E/AndroidRuntime(12204): at java.lang.reflect.Constructor.constructNative(Native Method)
01-27 02:50:19.070: E/AndroidRuntime(12204): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-27 02:50:19.070: E/AndroidRuntime(12204): ... 25 more
01-27 02:50:19.070: E/AndroidRuntime(12204): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:463)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.content.res.Resources.loadDrawable(Resources.java:1709)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.content.res.Resources.getDrawable(Resources.java:581)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.view.View.<init>(View.java:1951)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.widget.TextView.<init>(TextView.java:344)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.widget.Button.<init>(Button.java:108)
01-27 02:50:19.070: E/AndroidRuntime(12204): at android.widget.Button.<init>(Button.java:104)
01-27 02:50:19.070: E/AndroidRuntime(12204): ... 28 more