lawang code

lawang Code


Tanyakan kode disini

Buka File PDF Otomatis Android.

ditanyakan oleh Ahmad Rifa'i 4 tahun yang lalu

Saya ingin setelah download file PDF selesai, akan dibuka otomatis. Saya memakai Download Manager. Ini script untuk download :

    private TextView no;
    private TextView per;
    private EditText surat_fi;
    Context context=this;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.suratmasuk);

        no = (TextView) findViewById(R.id.ednomor);
        per = (TextView) findViewById(R.id.edperihal);

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
       JSONObject json = JSONSuratMasuk.getJSONfromURL("http://---");
       try{
       JSONArray  data = json.getJSONArray("data");
       for(int i=0;i<data.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject jsonobj = data.getJSONObject(i);
            map.put("nomor",  jsonobj.getString("nosurat"));
                map.put("perihal", jsonobj.getString("perihal"));
                map.put("surat", jsonobj.getString("surat"));
    mylist.add(map);
            }
    }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
        }
       ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.row,
        new String[] { "nomor", "perihal" },
        new int[] { R.id.lvnomor, R.id.lvperihal });
       setListAdapter(adapter);

        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                @SuppressWarnings("unchecked")
        HashMap<String, String> o = (HashMap<String, String>)
lv.getItemAtPosition(position);
                no.setText(String.valueOf(o.get("nomor")));
                per.setText(String.valueOf(o.get("perihal")));
                surat_fi.setText(String.valueOf(o.get("surat")));

               Boolean result=isDownloadManagerAvailable(getApplicationContext());
                if (result)
                    downloadFile();
                }

ini script methodenya :

   @SuppressLint("NewApi")
    public void downloadFile(){
String surfil = surat_fi.getText().toString();      
    String DownloadUrl = "http://---";
            String fs = DownloadUrl+surfil;
            DownloadManager.Request request = new DownloadManager.Request(Uri.parse(fs));
            request.setDescription("Sedang download");   //appears the same in Notification bar while downloading
            request.setTitle(surfil);                
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                request.allowScanningByMediaScanner();
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
            }
            request.setDestinationInExternalFilesDir(getApplicationContext(),null, surfil);
            DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
            manager.enqueue(request);
}


Saya ingin file PDF itu terbuka otomatis setelas proses download selesai. Saya sudah ada script untuk membuka file, tapi bingung mau saya taruh dimana.

Menampilkan 1-2 dari 2 hasil
Ahmad Rifa'i menjawab 4 tahun yang lalu :

maaf, sudah bisa gan.

Matur Tenkyu.


handita okviyanto menjawab 4 tahun yang lalu :

Sip gan..


Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 6
X 48
X 14
X 10
X 1
X 5
X 4
X 13
X 10

Bantuan

Help

Feedback

Help