SORU
21 Mayıs 2010, Cuma


Nasıl Android PDF oluşturmak için

Benim uygulamada bir bayt akışı ve telefon hafızasındaki pdf dosyasına dönüştürün. Nasıl bir pdf için bu hale? Ve Haritayı bir aktivite?

CEVAP
21 Mayıs 2010, Cuma


Bazı telefonlarda (Nexus One) ile gelen bir sürümü Quickoffice önceden yüklenmiş bu yüzden olabilir kadar kolay göndermeyi uygun Niyet bir kere kaydedilen dosyayı SD kart.

public class OpenPdf extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button = (Button) findViewById(R.id.OpenPdfButton);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                File file = new File("/sdcard/example.pdf");

                if (file.exists()) {
                    Uri path = Uri.fromFile(file);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(path, "application/pdf");
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                    try {
                        startActivity(intent);
                    } 
                    catch (ActivityNotFoundException e) {
                        Toast.makeText(OpenPdf.this, 
                            "No Application Available to View PDF", 
                            Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BiGSH0TROB

    BiGSH0TROB

    7 NİSAN 2011
  • FASHTAG

    FASHTAG

    5 EYLÜL 2012
  • Menglong Tav

    Menglong Tav

    18 Temmuz 2010