小编use*_*138的帖子

Android Notification.Builder:显示没有图标的通知

 String ns = Context.NOTIFICATION_SERVICE;
 NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

 int icon = R.drawable.ic_notification_icon;
 android.app.Notification.Builder nbuilder = new Notification.Builder(this);

 nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
 nbuilder.setContentText(msg);
 nbuilder.setOnlyAlertOnce(true);
 nbuilder.setOngoing(true);
 nbuilder.setSmallIcon(icon,level.level);
Run Code Online (Sandbox Code Playgroud)

如何隐藏或完全删除smallIcon?我试图不使用nbuilder.setSmallIcon,但结果是通知根本没有显示!

android android-notifications

13
推荐指数
3
解决办法
1万
查看次数

Android应用程序如何在应用程序内部存储和获取文件

我有一个应用程序,让我通过文件资源管理器选择一个文件(该文件存储在 SD 上),然后读取它。

我想修改它,因此它将文件直接放入应用程序中并从“内部”读取文件。我必须将文件放入项目中的哪里?我怎样才能访问它?

android file

6
推荐指数
1
解决办法
5196
查看次数

函数退出(退出代码)是否关闭了套接字描述符?

我用 c-unix 语言创建了一个多进程客户端 - 服务器。与客户端的每个连接都作为子进程进行管理。发生错误时,我只是调用函数 exit(EXIT_FAILURE),因为我读到该函数会关闭所有打开的流。问题是:我必须关闭客户端套接字描述符还是自动关闭?

我的代码的一个例子是:

while(1){
    if((client_sock=accept(ds_sock,&client,&s_client))==-1){
        printf("Accept error\n");
        exit(EXIT_FAILURE);
    }
    if(fork()==0){  //child
        if((close(ds_sock)==-1)){
            printf("Closing error\n");
            exit(EXIT_FAILURE);
        }
        if((read(client_sock,&up,sizeof(userpass)))==-1){
            printf("Error read\n");
            exit(EXIT_FAILURE); //Does this instruction close the client_sock too?
        }
Run Code Online (Sandbox Code Playgroud)

c sockets exit

5
推荐指数
1
解决办法
3076
查看次数

"没有对等证书"的android应用程序

我正在开发Android设备的应用程序(2.2).我正在尝试获取一个html页面.我使用的java代码似乎工作,所以我可以获得我想要的页面,但有时应用程序崩溃,我得到例外:"没有对等证书".发生这种情况时,如果我等待一个小时或者我改变网络,它会正常工作.有人知道如何解决这个问题吗?该网站是https://stud.infostud.uniroma1.it/Sest/Log/

我真的很抱歉我的英语,我希望你能理解!

ssl android httpconnection

4
推荐指数
1
解决办法
1万
查看次数

Android暂停广播接收器

我的应用程序中有一个广播接收器,等待屏幕打开/关闭.我想做的是:

public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
        pause some seconds...
        ...do something
    }
}
Run Code Online (Sandbox Code Playgroud)

如何将当前线程停止到onReceive方法?

multithreading android broadcastreceiver

0
推荐指数
1
解决办法
1626
查看次数