1、抖动动画
// 抖动
Animation shake =AnimationUtils.loadAnimation(PhoneLocationActivity.this,R.anim.shake);
//开始动画
view.startAnimation(shake);
抖动参数配置xml文件
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7"
android:toXDelta="10" />
2、震动的效果(真机中才有效果,模拟机不会震动)
Vibrator vibrator= (Vibrator) getSystemService(VIBRATOR_SERVICE);
// 震动的参数设置
vibrator.vibrate(newlong[] { 100, 300, 100, 300 }, -1);
SystemClock.sleep(800);
// 删除
vibrator.cancel();
清单中需要的权限
<span style="font-size:14px;"><uses-permissionandroid:name="android.permission.VIBRATE" /></span>
3、设置成前台进程
Notification noti = new Notification();
noti.icon = R.drawable.ic_launcher;
Intent intent = new Intent();
//在前台点击后打开的activity
intent.setAction("com.lmk.homeactivity");
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
noti.setLatestEventInfo(getApplicationContext(), "lmk", "lmklmklmk",contentIntent);
// 设置成前台进程
startForeground(110, noti);
Activity需要这样配置
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home" >
<intent-filter>
<action android:name="com.lmk.homeactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
效果图
又完成一篇笔记!!!