如何在主要活动中直接显示动态壁纸? [英] How to make directly show live wallpaper in main activity?

查看:125
本文介绍了如何在主要活动中直接显示动态壁纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用android直接在主要活动中显示动态壁纸?

How to make directly show live wallpaper in main activity with android ?

我要一个屏幕,

示例:

当我单击以编程时,我要定向动态壁纸设置壁纸"动态屏幕:

When I click to program I want to direct Live Wallpaper "Set Wallpaper" live screen:

请看样品图片 ![在此处输入图片描述] [1]

Sample Look Picture Please ![enter image description here][1]

http://i.stack.imgur.com/IFzTy.png

我不希望壁纸列表,我不想其他主要活动..我只想要当我单击程序时,我要定向动态壁纸设置壁纸"动态屏幕.

I don't want wallpaper list,I don't want main activity other button..I want only When I click to program I want to direct Live Wallpaper "Set Wallpaper" live screen.

对不起,我的英语不好.

Sorry , My english is bad..

我该怎么办? 请帮助我

How can I do? Please help me

我总共有4个Java代码:

I have total 4 java code:

Animationwallpaper.java Bokehrainbowcircle.java Bokehrainbowwallpaper.java MainActivity.Java

Animationwallpaper.java Bokehrainbowcircle.java Bokehrainbowwallpaper.java MainActivity.Java

And My manifest code:

<?xml version="1.0" encoding="utf-8"?>

<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.sample.livewallpaper.bokehrainbow" android:versionCode="1"
           android:versionName="1.0">

    <uses-sdk android:minSdkVersion="7" />
    <uses-feature android:name="android.software.live_wallpaper" />

    <!-- We need to request a permission to install a shortcut icon -->
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

    <application
       android:label="@string/wallpapers"
       android:icon="@drawable/icon">

        <service

           android:name="com.funnyphotoshoppictures.BokehRainbowWallpaper"
           android:permission="android.permission.BIND_WALLPAPER">
            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
            </intent-filter>
            <meta-data android:name="android.service.wallpaper" android:resource="@layout/bokeh" />
        </service>


        <activity

           android:name="com.funnyphotoshoppictures.AnimationWallpaper"
           android:theme="@android:style/Theme.WallpaperSettings"
           android:exported="true">
        </activity>

        <!-- Register the activity in the manifest -->
        <activity
           android:name="com.funnyphotoshoppictures.MainActivity"
           android:theme="@android:style/Theme.WallpaperSettings"
           android:screenOrientation="portrait"
           android:icon="@drawable/icon">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <supports-screens
       android:smallScreens="false"
       android:normalScreens="true"
       android:largeScreens="true" />
</manifest>

推荐答案

按下按钮后,执行以下代码. "try"中的代码意味着完全跳到您要定位的动态墙纸,而不是所有动态壁纸的画廊.似乎满足了您的要求,但仅适用于> android 4.1.

After button is pushed, execute these code. The codes inside "try" means jumping exactly to your targeted live wall paper but not the gallery of all of your live wallpapers. It seems fulfilled your requirement but it just works for >android 4.1.

捕获"中的代码表示如果手机不支持尝试"中的代码,则跳至所有动态壁纸的图片库.

The codes inside "catch" means jumping to the gallery of all of your live wallpapers if the phone doesn't support the code in "try".

希望它能对您有所帮助:)

Hopefully, it could help you :)

try{
       Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
       intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
        new ComponentName(MainActivity.this, com.abc.YourMainProgram.class));
       startActivity(intent);
}
catch(Exception e){
        Intent intent = new Intent();
        intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
        startActivity(intent);
}

这篇关于如何在主要活动中直接显示动态壁纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆