- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
据我所知,我的应用程序看起来已经完成,虽然它不是防弹的,但它应该可以完成测试工作,但问题是当我构建时,我遇到了这些错误。
Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1573
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1667
ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 117
ActivityThread$H.handleMessage(Message) line: 935
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3691
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 847
ZygoteInit.main(String[]) line: 605
NativeStart.main(String[]) line: not available [native method]
这是我的代码Main.java
package bitcoin.Virwox;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
public class Main extends Activity {
//Variables
ProgressDialog dialog = new ProgressDialog(null);
JSONObject jArray = new JSONObject();
int BTCSell;
int GBPBuy;
int Ammount;
int BTCSLLAmmount;
int GBPSLLAmmount;
int Total;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void Start(View view) {
dialog.setTitle("Please Wait");
dialog.setIcon(R.drawable.icon);
dialog.setMessage("Loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
Ammount = Integer.valueOf(findViewById(R.id.Amountinputtxt).toString());
GetInfo();
Process();
dialog.hide();
}
public void GetInfo() {
try {
BestBuySell();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
final CheckBox checkBox = (CheckBox) findViewById(R.id.VirwoxFeeChk);
if (checkBox.isChecked()) {
ProcessEstimates();
Total = GBPSLLAmmount;
}
else {
int holder;
holder = BTCSell*Ammount;
Total = (int)(holder/GBPBuy);
}
}
private void ProcessEstimates() {
try {
BTCSLL();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
GBPSLL();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void BTCSLL() throws Exception{
//retrieve data for BTC>SLL
try {
HttpClient httpclient = new DefaultHttpClient();
String http = "http://api.virwox.com/api/json.php?method=estimateMarketOrder&amount="+Ammount+"&orderType=SELL&instrument=BTC/SLL";
HttpGet httpget = new HttpGet(http);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
byte buffer[] = new byte[1024] ;
InputStream is = entity.getContent() ;
int numBytes = is.read(buffer) ;
is.close();
String entityContents = new String(buffer,0,numBytes) ;
Log.d("xxx",entityContents);
try {
jArray = new JSONObject(entityContents);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{}
//Parse Data
JSONArray result = jArray.getJSONArray("result");
//parse BTC>SLL
JSONObject f = result.getJSONObject(0);
BTCSLLAmmount = Integer.parseInt(f.getString("amount"));
}
public void GBPSLL() throws JSONException{
//retrieve data for SLL>GBP
try {
HttpClient httpclient = new DefaultHttpClient();
String http = "http://api.virwox.com/api/json.php?method=estimateMarketOrder&amount="+BTCSLLAmmount+"&orderType=BUY&instrument=SLL/GBP";
HttpGet httpget = new HttpGet(http);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
byte buffer[] = new byte[1024] ;
InputStream is = entity.getContent() ;
int numBytes = is.read(buffer) ;
is.close();
String entityContents = new String(buffer,0,numBytes) ;
Log.d("xxx",entityContents);
try {
jArray = new JSONObject(entityContents);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{}
//Parse Data
JSONArray result = jArray.getJSONArray("result");
//parse BTC>SLL
JSONObject e2 = result.getJSONObject(0);
GBPSLLAmmount = Integer.parseInt(e2.getString("amount"));
}
public void Process() {
CheckBox checkBox = (CheckBox) findViewById(R.id.PaypalFeeChk);
if (checkBox.isChecked()) {
Total = Total - 1;
}
TextView tv = (TextView)findViewById(R.id.Outputtxt);
tv.setText("Total: £" + Total + ".00");
CurrentRate();
}
public void CurrentRate(){
float holder;
holder = BTCSell/GBPBuy;
BigDecimal payment = new BigDecimal(holder);
NumberFormat n = NumberFormat.getCurrencyInstance(Locale.UK);
double doublePayment = payment.doubleValue();
String s = n.format(doublePayment);
TextView tv = (TextView)findViewById(R.id.CurrentRatetxt);
tv.setText(s);
}
public void BestBuySell() throws Exception, IOException{
//retrieve data
try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://api.virwox.com/api/json.php?method=getBestPrices&symbols[0]=BTC/SLL&symbols[1]=GBP/SLL");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
byte buffer[] = new byte[1024] ;
InputStream is = entity.getContent() ;
int numBytes = is.read(buffer) ;
is.close();
String entityContents = new String(buffer,0,numBytes) ;
Log.d("xxx",entityContents);
try {
jArray = new JSONObject(entityContents);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{}
}
finally{}
//parse info
JSONArray result = jArray.getJSONArray("result");
//parse BTC>SLL
JSONObject e = result.getJSONObject(0);
BTCSell = Integer.parseInt(e.getString("bestBuyPrice"));
//Parse SLL>GBP
e = result.getJSONObject(1);
GBPBuy = Integer.parseInt(e.getString("bestSellPrice"));
}
}
这是布局Main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout android:id="@+id/widget43" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:text="BTC->GBP" android:textSize="45sp" android:layout_width="fill_parent" android:layout_height="78px" android:layout_x="1dip" android:layout_y="20dip" android:gravity="center_horizontal" android:id="@+id/Title"></TextView>
<Button android:layout_width="350px" android:layout_height="wrap_content" android:layout_x="42dip" android:layout_y="298dip" android:text="Calculate" android:id="@+id/Button"></Button>
<TextView android:textSize="15sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="14dip" android:layout_y="388dip" android:text="Current Exchange rate: " android:id="@+id/Ratetxt"></TextView>
<CheckBox android:checked="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_y="148dip" android:layout_x="190dip" android:text="Paypal Fee" android:id="@+id/PaypalFeeChk"></CheckBox>
<CheckBox android:checked="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="190dip" android:layout_y="106dip" android:text="Virwox Fees" android:id="@+id/VirwoxFeeChk"></CheckBox>
<TextView android:layout_x="182dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_y="388dip" android:textSize="15sp" android:id="@+id/CurrentRatetxt" android:text="£0.00"></TextView>
<TextView android:layout_height="wrap_content" android:layout_x="1dip" android:layout_y="245dip" android:gravity="center" android:textSize="18sp" android:id="@+id/Outputtxt" android:text="£0.00" android:layout_width="fill_parent"></TextView>
<EditText android:text="EditText" android:layout_width="200px" android:layout_height="wrap_content" android:layout_x="48dip" android:layout_y="126dip" android:numeric="integer" android:id="@+id/Amountinputtxt"></EditText>
</AbsoluteLayout>
这是怎么造成的以及如何解决这个问题?
最佳答案
尝试在 onCreate 方法之前声明 Context 变量:
Context thisContext = this;
@Override
public void onCreate(Bundle savedInstanceState) {
然后当你声明时:
AlertDialog.Builder builder = new AlertDialog.Builder(thisContext);
使用上下文变量。
不要使用:
AlertDialog.Builder(this);
关于java - ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6005818/
在进行一些更改以提高可用性之前,我的应用程序运行良好。现在,它始终显示此错误:ActivityThread.performLaunchActivity(ActivityThread$ActivityC
每次在调试器中启动我的程序时,我都会收到 ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord,Intent) 错误。该
据我所知,我的应用程序看起来已经完成,虽然它不是防弹的,但它应该可以完成测试工作,但问题是当我构建时,我遇到了这些错误。 Thread [ main] (Suspended (exception Ru
我收到此错误 ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2585 当我开始一个
然后当我按 f8 a 我得到: ZygoteInit$methodandargscaller.run() source not found
对于我的 Android 应用程序,我在 Google Play 的开发者控制台中收到以下错误: java.lang.RuntimeException: Unable to instantiate a
从 Google Play 管理中心,java.lang.RuntimeException 发生时没有“Caused by:” 以下日志是从 Google Play 管理中心崩溃日志复制的。 适用于:
我花了两天时间对此进行研究并尝试了所有解决方案,但对我来说没有任何效果。以下是我的代码: LogCat: 12-27 19:12:13.950: D/AndroidRuntime(30835): Sh
我是一名优秀的程序员,十分优秀!