我有這樣的應用程序,我想安裝它(它是服務),但我沒有一個活動,所以我不能在我的設備上安裝並試用有人可以幫助我,請我想這是對照片序列livewallpaper像幻燈片,所以任何人都可以告訴我,我該怎麼辦?應該如何安裝這個應用程序?
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);
}
我有這個課呢 公共無效的步驟的onReceive(上下文範圍內,意圖意圖){ /*****對於開始服務****/ 意圖myIntent =新INTE nt(context,MainActivity.class); context.startService(myIntent); } } – CJS
BootUpReceiver。 – CJS
會議應用:錯誤共進午餐的活動 – CJS