-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallpaper.java
More file actions
76 lines (67 loc) · 2.05 KB
/
Copy pathwallpaper.java
File metadata and controls
76 lines (67 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.example.wallpaper;
import androidx.appcompat.app.AppCompatActivity;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
Timer mytimer;
Drawable drawable;
WallpaperManager wps;
int next =1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mytimer=new Timer();
wps=WallpaperManager.getInstance(this);
}
public void changewallpaper(View v)
{
setWallPaper();
}
public void setWallPaper()
{
mytimer.schedule(new TimerTask() {
@Override
public void run() {
if(next==1)
{
drawable=getResources().getDrawable(R.drawable.one);
next=2;
}
else if(next==2)
{
drawable=getResources().getDrawable(R.drawable.two);
next=3;
}
else if(next==3)
{
drawable=getResources().getDrawable(R.drawable.three);
next=4;
}
else if(next==4)
{
drawable=getResources().getDrawable(R.drawable.four);
next=5;
}
else if(next==5)
{
drawable=getResources().getDrawable(R.drawable.five);
next=1;
}
Bitmap img=((BitmapDrawable)drawable).getBitmap();
try{
wps.setBitmap(img);
} catch (IOException e) {
e.printStackTrace();
}
}
} , 500, 5000);
}
}