简体   繁体   English

在Android中使用JAVA无法解决异常处理程序?

[英]Exception Handler cannot be resolved using JAVA In Android?

I am newbie in android. 我是android的新手。 I have used this code in my project but this is giving me error at this line ExceptionHandler.logException(e); 我在我的项目中使用过这段代码,但是这行给了我错误ExceptionHandler.logException(e); and there is Error : 并且有错误:

ExceptionHandler cannot be resolved ExceptionHandler无法解析

catch (JSONException e) {
            errorMessage = getString(R.string.ExceptionGeneral);
            ExceptionHandler.logException(e);
            e.printStackTrace();
            }

I have already imported these references. 我已经导入了这些引用。 What other references I need to import Please mention. 我需要进口哪些其他参考请提及。

import java.io.IOException;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.json.JSONException;

Android中没有ExceptionHandler类,请使用Log

like Marton said, you need to use Log. 像Marton说的那样,你需要使用Log。 Log can basically be used to debug in the same way that you use "System.out.print("String")" in Java. Log可以基本上用于调试,就像在Java中使用“System.out.print(”String“)”一样。 So, you can have the Log class send messages to a view called LogCat within Android (you usually have to open this view yourself). 因此,您可以让Log类向Android中的一个名为LogCat的视图发送消息(您通常必须自己打开此视图)。

The way log works is like this: 日志的工作方式如下:

Log.v("Testing", "Show me this message");

Where 'v' is the type of Log message (there are a couple) and "Testing" is the tag you would like to associate it. 'v'是Log消息的类型(有几个),而“Testing”是您想要关联它的标记。 Tags are useful because you can filter by tags, so you could, for example, have LogCat temporarily only display Logs with the tag Testing. 标签很有用,因为您可以按标签进行过滤,因此您可以让LogCat暂时只显示标记为“测试”的日志。

You can't use all the classes in Java while working in Android platform. 在Android平台上工作时,不能使用Java中的所有类。 Google has chosen Java as a language for development in Android. 谷歌选择Java作为Android的开发语言。 Usage of ExceptionHandler is not allowed in android. android中不允许使用ExceptionHandler Please refer the packages list allowed in android development. 请参考android开发允许的包列表 You can use android.util.Log for logging in android applications 您可以使用android.util.Log登录Android应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM