gpt4 book ai didi

java.lang.IllegalArgumentException,我在游戏商店的崩溃报告中得到了这个异常,建议我如何解决这个问题......

转载 作者:行者123 更新时间:2023-12-02 02:47:13 25 4
gpt4 key购买 nike

Play商店显示崩溃报告中发生异常错误。请帮我解决这个问题。日志和java代码如下。在此我从我创建的api中获取了youtube url,但它可能是dialog.dismis方法的异常

日志报告

java.lang.IllegalArgumentException: 
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:412)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:338)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:118)
at android.app.Dialog.dismissDialog(Dialog.java:509)
at android.app.Dialog.dismiss(Dialog.java:492)
at com.sevakk.www.msg.Home$2.onResponse(Home.java:112)
at com.sevakk.www.msg.Home$2.onResponse(Home.java:104)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6838)
at java.lang.reflect.Method.invoke(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Java代码

 public class Home extends AppCompatActivity {

InterstitialAd mInterstitialAd;
String url = "http://xxxxxxxx/xxxxxx.php";
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
private RecyclerView.Adapter adapter;

List<Post_Data> list;

private InterstitialAd interstitial;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

AdView mAdView = (AdView) findViewById(R.id.adView);

AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

// Prepare the Interstitial Ad
interstitial = new InterstitialAd(Home.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.admob_interstitial_id));

recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
list = new ArrayList<Post_Data>();

getInfo();

interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}

private void getInfo() {
final ProgressDialog dialog = new ProgressDialog(Home.this);
dialog.setMessage("please wait...");
dialog.show();
final StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {


try {
JSONObject object = new JSONObject(response);
JSONArray jsonArray = object.getJSONArray("server_response");
dialog.dismiss();

for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object1 = jsonArray.getJSONObject(i);
Post_Data data = new Post_Data();
data.id = object1.getString("id");
data.url = object1.getString("url");
data.date = object1.getString("date");
data.postImageId = object1.getString("time");
data.text = object1.getString("desc");
data.eventdate = object1.getString("duration");
list.add(data);

}
} catch (JSONException e) {
e.printStackTrace();
}
adapter = new YoutTubeAdapter(Home.this, list);
recyclerView.setAdapter(adapter);
}
}, new Response.ErrorListener()

{
@Override
public void onErrorResponse(VolleyError error) {

Log.e(">>>", "error is :" + error.toString());

}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
return map;
}
};

RequestQueue queue = Volley.newRequestQueue(this);
int socketTimeout = 120000;//30 seconds - change to what you want
RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
request.setRetryPolicy(policy);
queue.add(request);
}

public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}

boolean doubleBackToExitPressedOnce = false;

@Override
public void onBackPressed() {
//super.onBackPressed();
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
return;
}
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this, "press back again to exit", Toast.LENGTH_SHORT).show();

new Handler().postDelayed(new Runnable() {

@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
}, 2000);
}
}

最佳答案

尝试替换第 112 行的以下代码。

 try {
if (!Home.this.isDestroyed()) {

if ((dialog != null) && dialog.isShowing()) {
dialog.dismiss();
}
} catch (IllegalArgumentException e) {
Log.e("Custom Tag", "Custom Message", e);
} catch ( Exception e) {
Log.e("Custom Tag", "Custom Message", e);
} finally {
dialog = null;
}

总体思路是,检查您的 Activity 是否被破坏,如果没有被破坏,检查您的对话框是否显示,然后关闭您的对话框。

关于java.lang.IllegalArgumentException,我在游戏商店的崩溃报告中得到了这个异常,建议我如何解决这个问题......,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44404274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com