应该如何安装这个应用程序?

How should Install this app?

我有这个应用程序,我想安装它(它是服务),但我没有 activity,所以我无法在我的设备上安装它来尝试,有人可以帮助我吗?我猜这是连续照片的动态壁纸,比如幻灯片所以谁能告诉我我该怎么做?

public class MainActivity extends WallpaperService{

 Handler handler;
private boolean visible;

public void onCreate()
{
    super.onCreate();
}

public void onDestroy()
{
    super.onDestroy();
}

public Engine onCreateEngine()
{
    return new CercleEngine();
}

class CercleEngine extends Engine
{
    public Bitmap image1, image2, image3;

    CercleEngine()
    {
        image1 = BitmapFactory.decodeResource(getResources(), R.drawable.greenww);
        image2 = BitmapFactory.decodeResource(getResources(), R.drawable.redww);
        image3 = BitmapFactory.decodeResource(getResources(), R.drawable.screen3);
    }

    public void onCreate(SurfaceHolder surfaceHolder)
    {
        super.onCreate(surfaceHolder);
    }

    public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels)
    {
        drawFrame();
    }





    void drawFrame()
    {
        final SurfaceHolder holder = getSurfaceHolder();

        Canvas c = null;
        try
        {
            c = holder.lockCanvas();
            if (c != null)
            {
                c.drawBitmap(image1, 0, 0, null);
                c.drawBitmap(image2, 0, 0, null);
                c.drawBitmap(image3, 0, 0, null);
            }
        } finally
        {
            if (c != null) holder.unlockCanvasAndPost(c);
        }
        handler.removeCallbacks(drawRunner);
        if (visible)
        {
            handler.postDelayed(drawRunner, 1000); // delay 1 sec
        }
    }
    private final Runnable drawRunner = new Runnable()
    {
        @Override
        public void run() {
            drawFrame();
        }

    };

}

清单

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mike.wallpaper2">
<uses-permission android:name="android.permission.SET_WALLPAPER" />





       <uses-permission android:name="android.permission.SET_WALLPAPER" />





<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">


    <service
        android:enabled="true"
        android:name=".MainActivity">
        <intent-filter>
            <action
                android:name = "me.myapp.MyAppService">
            </action>
        </intent-filter>
    </service>
    <receiver android:enabled="true"
        android:name=".BootUpReceiver">
        <intent-filter> <action
            android:name = "android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
</application>

BootUpReceiver

public class BootUpReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    /***** For start Service  ****/
    Intent myIntent = new Intent(context, MainActivity.class);
    context.startService(myIntent);
}

add/update清单中的代码

<service
    android:enabled="true"
    android:name=".MainActivity">
    <intent-filter>
        <action
            android:name = "com.example.mike.wallpaper2.MainActivity">
        </action>
    </intent-filter>
</service>
<receiver
    android:enabled="true"
    android:name=".BootReceiver">
    <intent-filter>
        <action android:name = "android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

还添加一个新的class

public class BootReceiver extends BroadcastReceiver {
 @Override
 public void onReceive(Context context, Intent intent) {
   Intent service = new Intent(context, MainActivity.class);
   context.startService(service);
 }
}

然后按照以下示例中提到的步骤进行操作 Start android application without activity

或重新启动您的设备此服务启动 运行

来自 EditConfiguration 午餐选项(无)