小编b.i*_*b.i的帖子

NotificationManager.cancel(id)在广播接收器内不起作用

Android:我正在尝试在安装软件包后取消通知栏中的通知.我正在做的是以下内容:

 public class MyBroadcastReceiver extends BroadcastReceiver {

                private static final String TAG = "MyBroadcastReceiver";

                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
                        Uri data = intent.getData();
                        //some code goes here
                        //get the id of the notification to cancel in some way
                        notificationhelper._completeNotificationManager.cancel(id);     
                        }
                }
            }
Run Code Online (Sandbox Code Playgroud)

哪里

public class notificationhelper {
    public static NotificationManager _completeNotificationManager = null;

    public void complete() {        
        if (_completeNotificationManager == null)
            _completeNotificationManager = (NotificationManager) _context.getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = new Notification( …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver notificationmanager

10
推荐指数
3
解决办法
2万
查看次数

Android:从服务器下载文件,并使用AsyncTask在通知栏中显示下载进度

我正在使用此示例从服务器下载文件,AsycTask并在通知栏中显示下载进度.我只是修改了doInBackground方法以便下载我的文件:

@Override
    protected Void doInBackground(String... Urls) {
        //This is where we would do the actual download stuff
        //for now I'm just going to loop for 10 seconds
        // publishing progress every second
        try {   
            URL url = new URL(Urls[0]);
            URLConnection connection = url.openConnection();
            connection.connect();
            // this will be useful so that you can show a typical 0-100%
            // progress bar
            int fileLength = connection.getContentLength();

            // download the file
            InputStream input = new BufferedInputStream(url.openStream());
            OutputStream …
Run Code Online (Sandbox Code Playgroud)

notifications android download android-asynctask

9
推荐指数
1
解决办法
9212
查看次数

从csv导入mysql as 0000-00-00的日期

我有一些数据保存为txt文件.我将txt文件保存为csv,以便使用我的sql workbench将其导入数据库.我正在做的是以下内容:

LOAD DATA LOCAL INFILE '/path/to/csv/file.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' ENCLOSED BY '"' lines terminated by '\n';
Run Code Online (Sandbox Code Playgroud)

但我的一个专栏是日期,它是作为0000-00-00导入的

如何以良好的方式导入它? 编辑 这是我的csv包含的内容:

id  task    hoursWorked begindate   enddate                         
0   task1   15  11/17/2012          11/18/2012                          
1   task2   20  11/18/2012          11/20/2012                          
2   task3   20  12/4/2012           12/5/2013                           
3   task4   22  1/5/2013            1/7/2013
Run Code Online (Sandbox Code Playgroud)

mysql csv import

8
推荐指数
2
解决办法
2万
查看次数

Android:网址的最大长度

你有没有人知道Android浏览器中网址的最大长度?

url android

5
推荐指数
0
解决办法
9024
查看次数

Android:检测安装应用程序的时间

我正在尝试使用DownloadManager该类从服务器下载Android应用程序,安装它然后检测安装何时完成.我使用两个接收器:一个用于检测下载过程,另一个用于检测安装过程.第一个接收器工作正常,但第二个接收器没有.我做错了什么?

DownloadManager dm = (DownloadManager) DownloadApplicationActivity.this.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request req = new DownloadManager.Request(Uri.parse(MY_LINK));
req.setTitle(MY_TITLE)
                .setDescription("Downloading ....")
                // download the package to the /sdcard/downlaod path.
                .setDestinationInExternalPublicDir(
                        Environment.DIRECTORY_DOWNLOADS,
                        MY_PATH);
        long enqueue = dm.enqueue(req);
BroadcastReceiver receiver= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
        Query query = new Query();
        query.setFilterById(enqueue);
        Cursor c =dm.query(query);
        if (c.moveToFirst()) {
            int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
            if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
                // show a notification bar.
                NotificationManager notificationManager = …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver android-download-manager

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

Android:无法使用DownloadManager将数据从服务器下载到内部存储器

我正在使用android中的DownloadManager类从服务器下载数据.数据保存到外部存储器.但我想将它们保存到内部存储器中.我做了我的研究,我发现的是来自这个链接.我尝试了第二种cyngus解决方案:

public static final String PROVIDER_NAME = "com.provider.Downloads";
public static final Uri CONTENT_URI = Uri.parse("content://"+ PROVIDER_NAME + "/downloads")

DownloadManager.Request req = new DownloadManager.Request(Uri.parse(LINK));
req.setDestinationUri(CONTENT_URI);
Run Code Online (Sandbox Code Playgroud)

它没有用,它给了我错误: java.lang.IllegalArgumentException: Not a file URI: content://com.provider.Downloads/downloads.我做错了什么?

memory android internal download-manager android-contentprovider

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

android:安装应用程序无需用户干预

我想在 Android 上安装应用程序而无需用户干预。我正在使用该权限INSTALL_PACKAGES,并将该应用程序安装在“/download/”文件夹中。下载完成后,会出现一个对话框,要求我安装该应用程序。如何隐藏此对话框并在无需用户干预的情况下安装应用程序?

installation android

2
推荐指数
1
解决办法
1250
查看次数

Android:使用DownloadManager类下载应用程序

我正在尝试使用DownloadManager该类在Android中下载非市场应用程序.我正在做的是以下内容:

DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Request request = new Request(Uri.parse("PATH_TO_MY_APP"));
long enqueue = dm.enqueue(request);
Run Code Online (Sandbox Code Playgroud)

通知栏显示我正在下载该应用程序.但我无法安装或在设备上找到它.我做错了什么?

android download

2
推荐指数
1
解决办法
5516
查看次数

android:使用包安装程序以编程方式安装应用程序

我正在以编程方式安装Android应用程序.出现一个"完成操作使用"对话框.他们之间有许多选项"Package Installer".如何在不要求用户选择的情况下隐式选择"包安装程序"?

编辑 我正在使用的代码是:

 Intent intent = new Intent();
intent .setDataAndType(Uri.fromFile(new File("/mnt/sdcard/download/App.apk")),"application/vnd.android.package-archive");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

android install action package-managers

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