小编Stu*_*son的帖子

Android:DownloadManager - Notification Sticking

我正在使用我的服务器下载图像Download Manager.

它下载文件并将其放在我想要的位置.但由于某种原因通知坚持,我似乎无法删除它.下载管理器的代码如下:

mDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

Uri uri = Uri.parse("URL"));

long enqueue = mDownloadManager.enqueue(new DownloadManager.Request(uri)
            .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
            .setAllowedOverRoaming(false)
            .setTitle("Title")
            .setDescription("File description")
            .setDestinationInExternalPublicDir("Folder", "Filename")
            .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE));

BroadcastReceiver onComplete = new BroadcastReceiver() {
    public void onReceive(Context ctxt, Intent intent) {
        Toast.makeText(getApplicationContext(), "Download Completed", Toast.LENGTH_SHORT).show();
    }
 };
Run Code Online (Sandbox Code Playgroud)

下载后如何删除通知?.

我已经尝试设置所有不同的通知可见性模式,没有运气.一旦完成,我可以从BroadcastReceiver做些什么吗?

android android-download-manager

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

带有ArrayAdapter的AlertDialog未显示项目列表

我想创建一个AlertDialog显示自定义对象列表Supplier.toString()已重写该方法以显示说明.

AlertDialog.Builder dialog = new AlertDialog.Builder(ExampleActivity.this);
dialog.setTitle("Title");
dialog.setMessage("Message:");

final ArrayAdapter<Supplier> adapter = new ArrayAdapter<Supplier>(
        ExampleActivity.this, android.R.layout.select_dialog_singlechoice);

adapter.add(new Supplier());
adapter.add(new Supplier());
adapter.add(new Supplier());

dialog.setAdapter(adapter, new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
});
dialog.setNegativeButton("Cancel", null);
dialog.show();
Run Code Online (Sandbox Code Playgroud)

从我看过的例子中,我发现这段代码没有明显错误.但是,当我运行它时,它不会按预期显示供应商对象的列表.我也尝试过使用setItemssetSingleChoiceItems方法AlertDialog.Builder.任何人都可以看到我错在哪里?

android android-alertdialog

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

Android Volley似乎没有发布HTTP参数

我在StackOverflow上看到了一些这样的问题,但我似乎无法弄清楚为什么这段代码对我不起作用.

public void postMethod(final String msg) {

    String url = "http://192.168.1.30/endpoint";

    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest sr = new StringRequest(Request.Method.POST, url, 
        new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            // Handle response...
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            // Handle error...
        }
    }){
        @Override
        protected Map<String,String> getParams(){
            Map<String,String> params = new HashMap<String, String>();
            params.put("msg", msg);

            return params;
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String,String> params = new HashMap<String, String>();
            params.put("Content-Type","application/x-www-form-urlencoded");
            return …
Run Code Online (Sandbox Code Playgroud)

android android-volley

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