在Android手机推出图库

在Android手机推出图库

本文介绍了在Android手机推出图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当用户点击该通知从我的应用程序启动画廊。我发现,这是唯一可能的,如果你知道包和图库应用程序的类名。我设法找到四个设备制造商一样,而且到目前为止,这code ++工程。
我只需要为摩托罗拉和LG的Andr​​oid手机包和类名。

谁能帮助?如果你是一个开发人员,拥有摩托罗拉,LG的Andr​​oid设备,它是对你来说很容易。你只需要在您的手机推出,而画廊连接到LogCat中,它会显示库的包和类名。

code:

 意图newIntent =新意图();//开画廊的Nexus加上谷歌的所有基于ROM的
如果(doesPackageExist(com.google.android.gallery3d))
    newIntent.setClassName(com.google.android.gallery3d,com.android.gallery3d.app.Gallery);//开画廊索尼Xperia Android设备
如果(doesPackageExist(com.android.gallery3d))
    newIntent.setClassName(com.android.gallery3d,com.android.gallery3d.app.Gallery);//开画廊的HTC Sense的Andr​​oid手机
如果(doesPackageExist(com.htc.album))
    newIntent.setClassName(com.htc.album,com.htc.album.AlbumMain.ActivityMainCarousel);//开画廊三星的TouchWiz基于ROM的
如果(doesPackageExist(com.cooliris.media))
    newIntent.setClassName(com.cooliris.media,com.cooliris.media.Gallery);startActivity(newIntent);

和检查包名称存在:

 公共布尔doesPackageExist(字符串targetPackage){    软件包管理系统下午= getPackageManager();
    尝试{
        PackageInfo信息= pm.getPackageInfo(targetPackage,PackageManager.GET_META_DATA);
    }赶上(ē的NameNotFoundException){
        返回false;
    }
    返回true;
}


解决方案

您应该能够通过一个基本的启动图库应用程序意图是这样的:

 意向意图=新意图(Intent.ACTION_PICK);
intent.setType(图像/ *);
startActivity(意向);

如果多个应用程序能够让你显示图像(如画廊和ESFileExplorer)可能触发应用选择器。

I am trying to launch the gallery from my app when user clicks on the notification. I have found that it is only possible if you know the package and the class name of the Gallery app. I have managed to find the same for four device manufacturers, and so far this code works.I just need the package and class name for Motorola and LG Android phones.

Can anyone help? It is very easy for you if you are a developer and own a Motorola or LG Android device. You just need to launch gallery in your phone while connected to LogCat, and it will show the package and class name of the Gallery.

CODE:

Intent newIntent = new Intent();

//open Gallery in Nexus plus All Google based ROMs
if(doesPackageExist("com.google.android.gallery3d"))
    newIntent.setClassName("com.google.android.gallery3d", "com.android.gallery3d.app.Gallery");

//open Gallery in Sony Xperia android devices
if(doesPackageExist("com.android.gallery3d"))
    newIntent.setClassName("com.android.gallery3d", "com.android.gallery3d.app.Gallery");

//open gallery in HTC Sense android phones
if(doesPackageExist("com.htc.album"))
    newIntent.setClassName("com.htc.album", "com.htc.album.AlbumMain.ActivityMainCarousel");

//open gallery in Samsung TouchWiz based ROMs
if(doesPackageExist("com.cooliris.media"))
    newIntent.setClassName("com.cooliris.media", "com.cooliris.media.Gallery");

startActivity(newIntent);

And to check if package name exists:

public boolean doesPackageExist(String targetPackage) {

    PackageManager pm = getPackageManager();
    try {
        PackageInfo info = pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA);
    } catch (NameNotFoundException e) {
        return false;
    }
    return true;
}
解决方案

You should be able to start the Gallery app via a basic Intent like this:

Intent intent =  new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivity(intent);

It may fire the app picker if more than one app is able to let you display images (e.g. Gallery and ESFileExplorer).

这篇关于在Android手机推出图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 12:51