├── app ├── .gitignore ├── libs │ └── lite-orm-1.9.2.jar ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── icon_app.png │ │ │ ├── ic_set_loc.xml │ │ │ ├── ic_flight_land.xml │ │ │ ├── ic_flight_takeoff.xml │ │ │ └── ic_bookmark.xml │ │ ├── drawable-xhdpi │ │ │ ├── icon_app.png │ │ │ ├── ic_keyboard_arrow_down_black_24dp.png │ │ │ ├── ic_keyboard_arrow_left_black_24dp.png │ │ │ ├── ic_keyboard_arrow_up_black_24dp.png │ │ │ └── ic_keyboard_arrow_right_black_24dp.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── attrs.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── list_item_bookmark_layout.xml │ │ │ ├── joystick_layout.xml │ │ │ ├── joystick_arrow.xml │ │ │ ├── activity_bookmark.xml │ │ │ ├── activity_fly.xml │ │ │ └── activity_main.xml │ │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── fakegps │ │ │ ├── BroadcastEvent.java │ │ │ ├── IJoyStickPresenter.java │ │ │ ├── model │ │ │ ├── LocPoint.java │ │ │ └── LocBookmark.java │ │ │ ├── FakeGpsApp.java │ │ │ ├── ui │ │ │ ├── JoyStickButton.java │ │ │ ├── BookmarkAdapter.java │ │ │ ├── BookmarkActivity.java │ │ │ ├── JoyStickView.java │ │ │ ├── FlyToActivity.java │ │ │ └── MainActivity.java │ │ │ ├── ScreenUtils.java │ │ │ ├── FakeGpsUtils.java │ │ │ ├── DbUtils.java │ │ │ ├── LocationThread.java │ │ │ └── JoyStickManager.java │ │ ├── aidl │ │ └── android │ │ │ └── location │ │ │ └── ILocationManager.aidl │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── keystore.debug.jks ├── screenshot ├── Screenshot_1.png ├── Screenshot_2.png └── Screenshot_3.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README_CN.md ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /keystore.debug.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/keystore.debug.jks -------------------------------------------------------------------------------- /app/libs/lite-orm-1.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/libs/lite-orm-1.9.2.jar -------------------------------------------------------------------------------- /screenshot/Screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/screenshot/Screenshot_1.png -------------------------------------------------------------------------------- /screenshot/Screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/screenshot/Screenshot_2.png -------------------------------------------------------------------------------- /screenshot/Screenshot_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/screenshot/Screenshot_3.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable/icon_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable-xhdpi/icon_app.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea/ 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_up_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_up_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_right_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/FakeGPS-1/master/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_right_black_24dp.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #66000000 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/BroadcastEvent.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps; 2 | 3 | /** 4 | * Created by tiger on 7/28/16. 5 | */ 6 | public class BroadcastEvent { 7 | 8 | public static final class BookMark { 9 | public static final String ACTION_BOOK_MARK_UPDATE = "action_book_mark_update"; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 150dp 6 | 200dp 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/IJoyStickPresenter.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps; 2 | 3 | /** 4 | * Created by tiger on 7/23/16. 5 | */ 6 | public interface IJoyStickPresenter { 7 | void onSetLocationClick(); 8 | 9 | void onFlyClick(); 10 | 11 | void onBookmarkLocationClick(); 12 | 13 | void onCopyLocationClick(); 14 | 15 | void onArrowUpClick(); 16 | 17 | void onArrowDownClick(); 18 | 19 | void onArrowLeftClick(); 20 | 21 | void onArrowRightClick(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_set_loc.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_flight_land.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_flight_takeoff.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bookmark.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/tiger/Androidsdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FakeGPS 3 | Start 4 | Stop 5 | Delete 6 | 7 | Bookmark 8 | Start Fly 9 | Stop Fly 10 | Fly To Location 11 | Set New Location 12 | Bookmark 13 | Move Step 14 | Move Step 15 | Latitude , Longitude 16 | Location: 17 | Fly Time(s) 18 | Bookmark Name 19 | No Bookmarks 20 | Save 21 | Cancel 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_bookmark_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/model/LocPoint.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by tiger on 7/23/16. 7 | */ 8 | public class LocPoint implements Serializable { 9 | static final long serialVersionUID = -1770575152720897533L; 10 | 11 | private double mLatitude; 12 | private double mLongitude; 13 | 14 | public LocPoint(LocPoint locPoint) { 15 | mLatitude = locPoint.getLatitude(); 16 | mLongitude = locPoint.getLongitude(); 17 | } 18 | 19 | public LocPoint(double latitude, double longitude) { 20 | mLatitude = latitude; 21 | mLongitude = longitude; 22 | } 23 | 24 | public double getLatitude() { 25 | return mLatitude; 26 | } 27 | 28 | public double getLongitude() { 29 | return mLongitude; 30 | } 31 | 32 | public void setLatitude(double latitude) { 33 | mLatitude = latitude; 34 | } 35 | 36 | public void setLongitude(double longitude) { 37 | mLongitude = longitude; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "(" + mLatitude + " , " + mLongitude + ")"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/FakeGpsApp.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.litesuits.orm.LiteOrm; 7 | 8 | /** 9 | * Created by tiger on 7/23/16. 10 | */ 11 | public class FakeGpsApp extends Application { 12 | 13 | private static Context sAppContext; 14 | private volatile static LiteOrm sLiteOrm; 15 | 16 | @Override 17 | protected void attachBaseContext(Context base) { 18 | super.attachBaseContext(base); 19 | sAppContext = base; 20 | } 21 | 22 | @Override 23 | public void onCreate() { 24 | super.onCreate(); 25 | JoyStickManager.get().init(this); 26 | } 27 | 28 | public static Context get() { 29 | return sAppContext; 30 | } 31 | 32 | public static LiteOrm getLiteOrm() { 33 | if (sLiteOrm == null) { 34 | synchronized (FakeGpsApp.class) { 35 | if (sLiteOrm == null) { 36 | sLiteOrm = LiteOrm.newSingleInstance(sAppContext, "fake_gps.db"); 37 | sLiteOrm.setDebugged(true); 38 | } 39 | } 40 | } 41 | return sLiteOrm; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | #FakeGPS 2 | 3 | FakeGPS是一个GPS设备模拟器,能够根据给定的坐标,输出GPS定位信号,并且带有全局悬浮窗的手柄,通过手柄上的方向按键,能够模拟用户在地图上行走。 4 | 5 | 按照惯例,先放截图。 6 | 7 | ![Screenshot_1](./screenshot/Screenshot_1.png) 8 | 9 | ![Screenshot_2](./screenshot/Screenshot_2.png) 10 | 11 | ![Screenshot_3](./screenshot/Screenshot_3.png) 12 | 13 | [下载地址](https://github.com/xiangtailiang/FakeGPS/releases/tag/1.0) 14 | 15 | #功能描述 16 | - 模拟真实的GPS设备,每秒输出GPS定位信号。 17 | - 具备两种运行模式:跳变模式和飞行模式。**跳变模式**:直接跳转到新的位置。**飞行模式**:根据给定的时间,以线性插值的方式慢慢飞行到新的位置。 18 | - 带有全局浮窗手柄,点击手柄上的方向按键会在当前位置上做一定的偏移(通过Move Step设置,单位为度数)。手柄单击一次移动一格,长按会连续移动。 19 | - 带有书签功能,点击使用,长按删除。 20 | - 长按书签按钮可以复制当前坐标到剪切板,方便分享给其他小伙伴。 21 | 22 | #安装说明 23 | 由于模拟位置需要借助系统的`INSTALL_LOCATION_PROVIDER`权限,因此FakeGPS 需要以system的权限,安装到system分区中。 24 | 25 | - 1、Root手机,获取system分区的读写权限。 26 | - 2、借助[Lucky Patcher](htt 27 | ps://lucky-patcher.netbew.com/) 把FakeGPS以系统应用的方式安装。 28 | - 3、打开Android系统设置开发者选项,取消“允许模拟位置”勾选。设置位置服务仅使用GPS设备。 29 | - 4、打开FakeGPS,点击Start,这个时候手柄会展示出来,如果没有弹出,请打开应用的悬浮窗显示权限(特别是MIUI和Flyme,权限默认是关闭的),然后打开地图应用(谷歌地图和高德地图测试可用)。查看是否能够定位到设置的坐标,点击手柄上的按键检查是否能够正常移动。 30 | 31 | #最后 32 | 时间比较匆忙,应用的体验还不是细致,有空再来完善。 33 | 34 | 欢迎各位同学发pull request来帮忙改进,谢谢大家。 35 | 36 | ## License 37 | [The MIT License (MIT)](http://opensource.org/licenses/MIT) 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/aidl/android/location/ILocationManager.aidl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package android.location; 18 | 19 | import android.location.Location; 20 | 21 | 22 | /** 23 | * System private API for talking with the location service. 24 | * 25 | * @hide 26 | */ 27 | interface ILocationManager 28 | { 29 | // --- internal --- 30 | 31 | // Used by location providers to tell the location manager when it has a new location. 32 | // Passive is true if the location is coming from the passive provider, in which case 33 | // it need not be shared with other providers. 34 | void reportLocation(in Location location, boolean passive); 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/joystick_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 18 | 19 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.github.fakegps" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | signingConfigs { 22 | debug { 23 | storeFile file('../keystore.debug.jks') 24 | storePassword project.hasProperty('STOREPASS') ? STOREPASS : 'apptest' 25 | keyAlias project.hasProperty('KEYALIAS') ? KEYALIAS : 'apptest' 26 | keyPassword project.hasProperty('KEYPASS') ? KEYPASS : 'apptest' 27 | } 28 | } 29 | 30 | applicationVariants.all { variant -> 31 | variant.outputs.each { output -> 32 | def outputFile = output.outputFile 33 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 34 | def fileName = "FakeGPS_v${defaultConfig.versionName}.apk" 35 | output.outputFile = new File(outputFile.parent, fileName) 36 | } 37 | } 38 | } 39 | 40 | } 41 | 42 | dependencies { 43 | compile fileTree(include: ['*.jar'], dir: 'libs') 44 | testCompile 'junit:junit:4.12' 45 | compile files('libs/lite-orm-1.9.2.jar') 46 | compile 'com.android.support:appcompat-v7:23.4.0' 47 | compile 'com.android.support:support-v4:23.4.0' 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/joystick_arrow.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/model/LocBookmark.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps.model; 2 | 3 | import com.litesuits.orm.db.annotation.Column; 4 | import com.litesuits.orm.db.annotation.NotNull; 5 | import com.litesuits.orm.db.annotation.PrimaryKey; 6 | import com.litesuits.orm.db.annotation.Table; 7 | import com.litesuits.orm.db.enums.AssignType; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * bookmark for location 13 | * Created by tiger on 7/23/16. 14 | */ 15 | @Table("LocBookmark") 16 | public class LocBookmark implements Serializable{ 17 | static final long serialVersionUID =-1770575152720897666L; 18 | 19 | @PrimaryKey(AssignType.AUTO_INCREMENT) 20 | @Column("_id") 21 | private int id; 22 | 23 | @NotNull 24 | private String mName; 25 | 26 | private LocPoint mLocPoint; 27 | 28 | 29 | public LocBookmark() { 30 | } 31 | 32 | public LocBookmark(String name, LocPoint locPoint) { 33 | mName = name; 34 | mLocPoint = locPoint; 35 | } 36 | 37 | public String getName() { 38 | return mName; 39 | } 40 | 41 | public void setName(String name) { 42 | mName = name; 43 | } 44 | 45 | public LocPoint getLocPoint() { 46 | return mLocPoint; 47 | } 48 | 49 | public void setLocPoint(LocPoint locPoint) { 50 | mLocPoint = locPoint; 51 | } 52 | 53 | public int getId() { 54 | return id; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | StringBuilder builder = new StringBuilder("LocBookmark: "); 60 | builder.append(mName); 61 | builder.append(" "); 62 | builder.append(mLocPoint != null ? mLocPoint.toString() : "loc null"); 63 | 64 | return builder.toString(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/fakegps/ui/JoyStickButton.java: -------------------------------------------------------------------------------- 1 | package com.github.fakegps.ui; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.util.Log; 6 | import android.view.MotionEvent; 7 | import android.widget.ImageButton; 8 | 9 | /** 10 | * Button can keep invoke click event when keep pressed 11 | * Created by tiger on 7/23/16. 12 | */ 13 | public class JoyStickButton extends ImageButton { 14 | 15 | private static final String TAG = "JoyStickButton"; 16 | 17 | private boolean mIsPressDown = false; 18 | 19 | public JoyStickButton(Context context) { 20 | super(context); 21 | } 22 | 23 | public JoyStickButton(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | } 26 | 27 | @Override 28 | public boolean onTouchEvent(MotionEvent event) { 29 | final int action = event.getAction(); 30 | switch (action & MotionEvent.ACTION_MASK) { 31 | case MotionEvent.ACTION_DOWN: 32 | mIsPressDown = true; 33 | postDelayed(mLongPressDetectorRunnable, 1000); 34 | break; 35 | 36 | case MotionEvent.ACTION_UP: 37 | case MotionEvent.ACTION_CANCEL: 38 | removeCallbacks(mLongPressDetectorRunnable); 39 | mIsPressDown = false; 40 | break; 41 | 42 | } 43 | 44 | return super.onTouchEvent(event); 45 | 46 | } 47 | 48 | 49 | private Runnable mLongPressDetectorRunnable = new Runnable() { 50 | @Override 51 | public void run() { 52 | if (mIsPressDown) { 53 | Log.d(TAG, "invoke click"); 54 | performClick(); 55 | postDelayed(this, 500); 56 | } 57 | } 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_bookmark.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 25 | 26 | 30 |