日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android tv outofmem,java.lang.OutOfMemoryError:尝试抛出OutOfMemoryErr...

發布時間:2024/1/8 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android tv outofmem,java.lang.OutOfMemoryError:尝试抛出OutOfMemoryErr... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我正在嘗試將用戶提供的lat long值與數據庫中的lat long值進行比較.如果它們彼此的半徑在15 km之內,則應更改textview.

但是我面臨以下錯誤,

我的數據庫包含值來源lat = 19.218418源長= 73.08661

Des lat = 18.9766017 des long = 72.8326658.用戶提供的值是

源緯度= 19.2213935源緯度= 73.081532目標緯度= 18.9632933經度緯度= 72.8324848.

E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.example.hitesh.nearby, PID: 2156

java.lang.IllegalStateException: Could not execute method for android:onClick

at android.view.View$DeclaredOnClickListener.onClick(View.java:5347)

at android.view.View.performClick(View.java:6267)

at android.view.View$PerformClick.run(View.java:24763)

at android.os.Handler.handleCallback(Handler.java:789)

at android.os.Handler.dispatchMessage(Handler.java:98)

at android.os.Looper.loop(Looper.java:164)

at android.app.ActivityThread.main(ActivityThread.java:6548)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Caused by: java.lang.reflect.InvocationTargetException

at java.lang.reflect.Method.invoke(Native Method)

at android.view.View$DeclaredOnClickListener.onClick(View.java:5342)

at android.view.View.performClick(View.java:6267)?

at android.view.View$PerformClick.run(View.java:24763)?

at android.os.Handler.handleCallback(Handler.java:789)?

at android.os.Handler.dispatchMessage(Handler.java:98)?

at android.os.Looper.loop(Looper.java:164)?

at android.app.ActivityThread.main(ActivityThread.java:6548)?

at java.lang.reflect.Method.invoke(Native Method)?

at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)?

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)?

Caused by: java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available

Result.java

public class result extends Activity {

DatabaseHelper myDb;

@Override

protected void onCreate(Bundle savedInstanceState) {

myDb = new DatabaseHelper(this);

super.onCreate(savedInstanceState);

setContentView(R.layout.layout_result);

String url = getIntent().getExtras().getString("username");

String url1 = getIntent().getExtras().getString("username1");

TextView tv= (TextView)findViewById(R.id.textView2);

TextView tv1= (TextView)findViewById(R.id.textView5);

String[] separated = url.split("_");

String srclat = separated[0];

Double dsrclat= Double.parseDouble(srclat);

String srclng = separated[1];

Double dsrclng= Double.parseDouble(srclng);

String[] separated1 = url.split("_");

String deslat = separated1[0];

Double ddeslat= Double.parseDouble(deslat);

String deslng = separated1[1];

Double ddeslng= Double.parseDouble(deslng);

tv.setText(url);

tv1.setText(url1);

}

public void Database(View view){

Intent intent = new Intent(result.this, feeder.class);

startActivity(intent);

}

public void NearestValue(View view){

TextView tv= (TextView)findViewById(R.id.textView2);

String s1 = tv.getText().toString();

String[] separated = s1.split("_");

String deslat = separated[0];

Double Lat= Double.parseDouble(deslat);

String deslng = separated[1];

Double Lng= Double.parseDouble(deslng);

ArrayList ssList = new ArrayList<>();

ssList = myDb.countDatabase(Lat,Lng);

int ssize = ssList.size();

TextView tvvv = (TextView) findViewById(R.id.textView8);

for(int i=0;i

tvvv.setText(ssList.get(i));

}

TextView tv1= (TextView)findViewById(R.id.textView5);

String s11 = tv1.getText().toString();

String[] separated1 = s11.split("_");

String deslat1 = separated1[0];

Double Lat1= Double.parseDouble(deslat1);

String deslng1 = separated1[1];

Double Lng1= Double.parseDouble(deslng1);

ArrayList ddList = new ArrayList<>();

ddList = myDb.countDatabase1(Lat1,Lng1);

int dsize = ddList.size();

TextView tvvvv = (TextView) findViewById(R.id.textView9);

for(int i=0;i

tvvv.setText(ddList.get(i));

}

for(int i=0;i

String source = ssList.get(i);

for(int j=0;j

String destination = ddList.get(j);

String src = myDb.findBus(source, destination);

TextView tvv = (TextView) findViewById(R.id.textView7);

tvv.setText(src);

}

}

}

}

DatabaseHelper

public class DatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "Nearby.db";

public static final String TABLE_NAME = "halt_details";

public static final String COL_2 = "snme";

public static final String COL_3 = "slati";

public static final String COL_4 = "slong";

public static final String COL_5 = "dnme";

public static final String COL_6 = "dlati";

public static final String COL_7 = "dlong";

public static final String COL_8 = "buses";

public DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, 1);

}

@Override

public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, snme VARCHAR, slati DOUBLE, slong DOUBLE, dnme VARCHAR, dlati DOUBLE, dlong DOUBLE, buses VARCHAR)");

}

@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);

onCreate(db);

}

public void insertData(String sname, Double slat, Double slng, String dname, Double dlat, Double dlng, String bus) {

SQLiteDatabase db = this.getWritableDatabase();

ContentValues contentValues = new ContentValues();

contentValues.put("snme",sname);

contentValues.put("slati",slat);

contentValues.put("slong",slng);

contentValues.put("dnme",dname);

contentValues.put("dlati",dlat);

contentValues.put("dlong",dlng);

contentValues.put("buses",bus);

db.insert(TABLE_NAME,null ,contentValues);

}

public void clearDatabase() {

SQLiteDatabase db = this.getWritableDatabase();

String clearDBQuery = "DELETE FROM "+TABLE_NAME;

db.execSQL(clearDBQuery);

}

public ArrayList countDatabase(Double LAT, Double LNG) {

String sourcename=null;

double earthRadius = 6371.75;

ArrayList sList = new ArrayList<>();

SQLiteDatabase db = this.getWritableDatabase();

Cursor mCount= db.rawQuery("SELECT * FROM " + DatabaseHelper.TABLE_NAME + " WHERE " + DatabaseHelper.COL_3 + " BETWEEN (" +LAT+"- 0.1) AND ("+LAT+" + 0.1) AND " + DatabaseHelper.COL_4 + " BETWEEN (" +LNG+"- 0.1) AND ("+LNG+" + 0.1)", null);

mCount.moveToNext();

while (mCount.moveToFirst()) {

double Latitude = mCount.getDouble(2);

double Longitude = mCount.getDouble(3);

double dLat = Math.toRadians(Latitude-LAT);

double dLng = Math.toRadians(Longitude-LNG);

double sindLat = Math.sin(dLat / 2);

double sindLng = Math.sin(dLng / 2);

double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(Math.toRadians(LAT)) * Math.cos(Math.toRadians(Latitude));

double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

double dist = earthRadius * c;

if (dist<15){

sourcename=mCount.getString(1);

sList.add(sourcename);

}

}

mCount.close();

return sList;

}

public ArrayList countDatabase1(Double LAT, Double LNG) {

String destinationname=null;

ArrayList dList = new ArrayList<>();

double earthRadius = 6371.75;

SQLiteDatabase db = this.getWritableDatabase();

Cursor mCount= db.rawQuery("SELECT * FROM " + DatabaseHelper.TABLE_NAME + " WHERE " + DatabaseHelper.COL_3 + " BETWEEN (" +LAT+"- 0.1) AND ("+LAT+" + 0.1) AND " + DatabaseHelper.COL_4 + " BETWEEN (" +LNG+"- 0.1) AND ("+LNG+" + 0.1)", null);

mCount.moveToFirst();

while (mCount.moveToNext() ) {

double Latitude = mCount.getDouble(2);

double Longitude = mCount.getDouble(3);

double dLat = Math.toRadians(Latitude-LAT);

double dLng = Math.toRadians(Longitude-LNG);

double sindLat = Math.sin(dLat / 2);

double sindLng = Math.sin(dLng / 2);

double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(Math.toRadians(LAT)) * Math.cos(Math.toRadians(Latitude));

double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

double dist = earthRadius * c;

if (dist<15){

destinationname = mCount.getString(4);

dList.add(destinationname);

}

}

mCount.close();

return dList;

}

public String findBus(String sourcename, String desname){

SQLiteDatabase db = this.getWritableDatabase();

Cursor mCount= db.rawQuery("select count(*) from search_table where name='" + sourcename + "' AND dname='"+desname+"'", null);

mCount.moveToFirst();

String src= mCount.getString(1);

mCount.close();

return src;

}

public Cursor getAllData() {

SQLiteDatabase db = this.getWritableDatabase();

Cursor res = db.rawQuery("select * from " + TABLE_NAME, null);

return res;

}

}

總結

以上是生活随笔為你收集整理的android tv outofmem,java.lang.OutOfMemoryError:尝试抛出OutOfMemoryErr...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。