Repository navigation
Home
dips25 edited this page Jun 3, 2026
·
1 revision
Welcome to the ChatHead2 wiki!
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
implementation("com.github.dips25:ChatHead2:v1.1")
public class MainActivity extends AppCompatActivity implements ChatHeadListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startChatHead();
}
private void startChatHead() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName())
);
startActivityForResult(intent, 1001);
} else {
// Permission already granted
startChatHeadService();
}
}
}
private void startChatHeadService() {
ChatHead chatHead = new ChatHead(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1001) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.canDrawOverlays(this)) {
// Permission granted
startChatHeadService();
} else {
Toast.makeText(this,
"Overlay permission denied",
Toast.LENGTH_SHORT).show();
}
}
}
}
@Override
public void onChatHeadClicked() {
Log.d(MainActivity.class.getName(), "onChatHeadClicked");
}
}
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle_drawable"
android:scaleType="centerInside"
xmlns:android="http://schemas.android.com/apk/res/android" />