小编ePe*_*ace的帖子

Android上的Pkpass

有一个Android应用程序,Passwallet,能够解释用于苹果应用程序Passbook的pkpass文件(https://play.google.com/store/apps/details?id=com.attidomobile.passwallet)

我想知道如何阅读pkpass文件.

Pkpass文件似乎是包含json文件中所有信息的zip文件.pkpass文件是否有默认结构?如果是这样的话是什么?什么是将其导入Android应用程序的好方法?


对于想知道如何阅读pkpass文件内容的人,请参考以下代码:

我使用pkpass文件的intent过滤器设置了此活动

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:mimeType="application/vnd-com.apple.pkpass"
                android:scheme="content" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:mimeType="application/vnd.apple.pkpass"
                android:scheme="content" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:mimeType="application/vnd-com.apple.pkpass"
                android:scheme="file" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:mimeType="application/vnd.apple.pkpass"
                android:scheme="file" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
Intent intent = getIntent();
Uri uri = intent.getData();
String scheme = uri.getScheme();

if(ContentResolver.SCHEME_CONTENT.equals(scheme)) {
    try {
        InputStream attachment …
Run Code Online (Sandbox Code Playgroud)

android passbook

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

Android Webview Redirect循环

我的项目中有一个Webview.

有些页面使用javascript链接到其他页面.

即.我点击链接到第2页的链接1.在第2页,javascript重定向到第3页.

在第3页中,我捕获onBackpress并检查webview是否可以访问.如果可以,我调用webview.goBack().

但这样做会打开第2页,然后第2页自动重定向到第3页.使用户很难退出活动.

有谁知道如何防止重定向循环?

android webview

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

下载图片网址包含"è"

我尝试下载以下网址中的图片:

http://upload.tapcrowd.com//cache/ /_cp_100_100_stand_filière_300x212.jpg

正如您在浏览器中看到的那样,它显示了一个图像,但在我的应用程序中,我得到了一个FileNotFoundException.

但是,如果我将图像的网址从"è"更改为"e".我可以成功将其下载到我的应用程序中.然而,这只是一个临时解决方案,因为它需要能够使用unicode标志下载图像.

我怎样才能做到这一点?

用于下载图像的方法:

        Bitmap bitmap = null;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        conn.setInstanceFollowRedirects(true);
        InputStream is = conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();
        bitmap = decodeFile(f, maxheight, maxwidth);
Run Code Online (Sandbox Code Playgroud)

结果代码对我有用:

        Bitmap bitmap = null;
        int slashIndex = url.lastIndexOf('/');
        String filename = url.substring(slashIndex + 1);
        filename = URLEncoder.encode(filename, "UTF-8");
        url = url.subSequence(0, slashIndex + 1) + filename;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000); …
Run Code Online (Sandbox Code Playgroud)

android image

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

标签 统计

android ×3

image ×1

passbook ×1

webview ×1