I would like to create such as "Common" library for android, but I have problems with configuring it in Intellij IDEA.
Let's say, what I would like to have ActivityHelper class which looks like this:
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
public class ActivityHelpers
{
public static void unlockScreen(Activity activity)
{
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
public static void clearFlags(Activity activity)
{
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
window.clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}
I added new module, "Gradle: Java Library" under Android section, then set up Android API 19 Platform as Module SDK in Modules settings.
Looks like editor can see import android.app.Activity;
, but compilation fails with:
Error:(3, 19) Gradle: error: package android.app does not exist
etc.
Can it be done somehow?
创建模块时,请寻找“ Android库”模块而不是“ Java库”模块。
Found it!
You can create library project in Intellij IDEA 13 by Gradle: Android Module
and then selecting Mark this project as a library
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.