我写SD卡时遇到问题,这里是代码:(对不起代码的布局,只需复制它)
public class SaveAndReadManager {
private String result;
private String saveFileName = "eventlist_savefile";
public String writeToFile( ArrayList<Event> arrlEvents ){
FileOutputStream fos = null;
ObjectOutputStream out = null;
try{
File root = Environment.getExternalStorageDirectory();
if( root.canWrite() ){
fos = new FileOutputStream( saveFileName );
out = new ObjectOutputStream( fos );
out.writeObject( arrlEvents );
result = "File written";
out.close();
}else{
result = "file cant write";
}
}catch( IOException e ){
e.printStackTrace();
result = "file not written";
}
return result;
}
public boolean readFromFile(){
return …Run Code Online (Sandbox Code Playgroud) 我想设计这种布局,它将有一个标题和一个背景图像,如下图所示TextView,每个分隔符的中心有三个s。当TextViews 文本大小之一增加时,其他TextViews 将保持在同一位置。
我怎样才能做到这一点?
我的一个项目的软件包中有一个主要方法。说,包裹是com.ant.car。我正在尝试运行和/或调试此主要方法,并且不断收到错误消息Could not find or load main class com.ant.car。
我已经搜索了这个问题,似乎无法弄清楚出什么问题了。
1)我检查了运行配置。在运行->运行配置中,我检查了Main类是否为com.ant.car。
2)我已经检查了构建路径。如果右键单击该项目,则选择“构建”->“构建路径”,然后在“库”选项卡下确保没有丢失带有红色X的文件夹。
不太确定还要做什么。有什么建议么?
这是我的代码,我想在用户点击通知时打开一个 URL。
这是代码:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setData(Uri.parse(link));
Notification myNotification = new NotificationCompat.Builder(ctx)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(false)
.setLargeIcon(remote_picture)
.setContentTitle(onvan)
.setContentIntent(notificationIntent)
.setContentText(msg)
.setStyle(notiStyle)
.build();
notificationManager.notify(1, myNotification);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:setContentIntent(PendingIntent)类型中的方法NotificationCompat.Builder不适用于参数(意图)
我究竟做错了什么?当用户单击通知时,如何告诉它打开浏览器?
我需要使用Retrofit多次调用API REST,并在中显示响应ListView,但我不知道该怎么做,因此此代码不起作用。
模型
@GET("apks/{sha256}")
Call<DatoAPI> getTask2(@Path("sha256") String hash, @Query("Authorization") String key);
Run Code Online (Sandbox Code Playgroud)
实作
for (String s: hash) {
Call<DatoAPI> call = services.getTask2(s, API.API_KEY);
call.enqueue(new Callback<DatoAPI>() {
@Override
public void onResponse(Call<DatoAPI> call, Response<DatoAPI> response) {
if (response.isSuccessful()) {
datoAPI = response.body();
items.add(datoAPI.getApp());
}
}
@Override
public void onFailure(Call<DatoAPI> call, Throwable t) {
Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过call.execute()和同样的问题,我想在显示此响应,ListView但它不起作用。
首先:我知道 JSON 应该包含一个带有键值对的数组,但它不是我的 API,所以我无法更改它。
响应如下所示:
{
"translations": {
"my.key.nr.0": "Value 0",
"my.key.nr.1": "Value 1",
"my.key.nr.2": "Value 2",
"my.key.nr.3": "Value 3",
},
"hash": "123xyz",
"length": 3,
"language": "de"
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,这是我的 DTO:
data class TranslationsDto(
val translations: ??????????, // <-- dont't know what to use here
val hash: String?,
val length: Int?,
val language: String?
)
Run Code Online (Sandbox Code Playgroud)
最后,这是我的问题:
我需要解析我可以在我的应用程序中使用的 DTO 的响应(至少 Retrofit 应该解析响应)。如果 的值translations是一个数组,那就没有问题,但我不知道如何解析这个 JSON 结构。
也许你们有人有一些想法?
我刚刚使用目标 SDK 版本 29 提交了我的应用程序,但我面临一些崩溃,我可以将其降级到 28 并再次提交吗?
我在尝试启动hiveUbuntu 14.04 LTS 时遇到以下异常,Caused by: java.sql.SQLException: Failed to create database 'metastore_db', see the next exception for details.Hadoop安装正确且工作正常.请告诉我任何人有什么问题?
我试图在 WebView 中加载本地 html 文件,但它总是给出错误 new::ERR_FILE_NOT_FOUND 我已附加我正在使用的代码图像和文件目录。我已经尝试过使用不同的目录,但它不起作用。
将文件目录更改为res文件夹、res/raw文件夹。尝试加载不同的 html 它确实加载了 webvlinks
路径和代码图片在这里
当我打开一个项目时,我目前遇到了这个问题:
事件日志中显示的错误:
无法检测 adb 版本,退出值:0xc0000409,adb 输出:adb.exe F 11-11 09:55:06 17768 944 fdevent_poll.cpp:64] 未能创建 fdevent 中断套接字对:无效参数
事件日志中显示的错误:
模拟器:模拟器:错误:AdbHostServer.cpp:93:无法连接到端口上的 adb 守护进程:5037