誰もがここのような明るスクリーンフィルターを実装する方法のアイデアを持っています:明るスクリーンフィルター
http://www.appbrain.com/app/screen-filter/com.haxor
私は出発点が必要と私はそれを行う方法を見つけ出すことはできません。
誰もがここのような明るスクリーンフィルターを実装する方法のアイデアを持っています:明るスクリーンフィルター
http://www.appbrain.com/app/screen-filter/com.haxor
私は出発点が必要と私はそれを行う方法を見つけ出すことはできません。
タッチが通過できるように透明なフルスクリーンアクティビティを作成するだけです。タッチがcontentViewを設定する前に使用して、次のウィンドウのフラグを渡すようにするには:調整する次に
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#33000000">
</LinearLayout>
:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Window window = getWindow();
// Let touches go through to apps/activities underneath.
window.addFlags(FLAG_NOT_TOUCHABLE);
// Now set up content view
setContentView(R.layout.main);
}
あなたのmain.xmlレイアウトファイルの場合は、単に透明な背景を持つ全画面のLinearLayoutを使います
findViewById(R.id.background).setBackgroundColor(0x66000000);
あなたはまた、これを試すCA:「明るさ」だけでどこかにあなたのコードから背景色の値を変更
あなたがこれを使用することはできません。もちろん、protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.max_bright);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100/100.0f;
getWindow().setAttributes(lp);
}
生産コードですが、遊んでいる場合...それは使用しています。このUndocumented hack
を試してみてください。
private void setBrightness(int brightness) {
try {
IHardwareService hardware = IHardwareService.Stub.asInterface(
ServiceManager.getService("hardware"));
if (hardware != null) {
hardware.setScreenBacklight(brightness);
}
} catch (RemoteException doe) {
}
}
は、それがこの権限を使用していることを忘れないでください:
<uses-permission android:name="android.permission.HARDWARE_TEST"/>
ここでhardware09.jarを見つけることができますか?このチュートリアル(http://www.tutorialforandroid.com/2009/01/changing-screen-brightness.html) – noobProgrammer
実際にこのリンクは壊れています... – Device
インスタンスを取得します。 WindowManagerの。
WindowManager windowManager = (WindowManager) Class.forName("android.view.WindowManagerImpl").getMethod("getDefault", new Class[0]).invoke(null, new Object[0]);
タッチがに渡されるようにクリックできない、フォーカス可能ではない、長くはないクリッカブル、などなど、あなたのビューを設定し、フル画面レイアウトXML(fill_parent
に設定されたレイアウトパラメータ)
を作成します。あなたのアプリとアプリはそれを検出することができます。
view.setFocusable(false);
view.setClickable(false);
view.setKeepScreenOn(false);
view.setLongClickable(false);
view.setFocusableInTouchMode(false);
タイプandroid.view.WindowManager.LayoutParams
のレイアウトパラメータを作成します。 LayoutParams layoutParams = new LayoutParams();
設定レイアウトの高さなどのパラメータ、幅など
layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.flags = 280; // You can try LayoutParams.FLAG_FULLSCREEN too
layoutParams.format = PixelFormat.TRANSLUCENT; // You can try different formats
layoutParams.windowAnimations = android.R.style.Animation_Toast; // You can use only animations that the system to can access
layoutParams.type = LayoutParams.TYPE_SYSTEM_OVERLAY;
layoutParams.gravity = Gravity.BOTTOM;
layoutParams.x = 0;
layoutParams.y = 0;
layoutParams.verticalWeight = 1.0F;
layoutParams.horizontalWeight = 1.0F;
layoutParams.verticalMargin = 0.0F;
layoutParams.horizontalMargin = 0.0F;
キーステップ:あなたはあなたが必要な明るさの何パーセントに設定することができます。 layoutParams.setBackgroundDrawable(getBackgroundDrawable(i));
private Drawable getBackgroundDrawable(int i) {
int j = 255 - (int) Math.round(255D * Math.exp(4D * ((double) i/100D) - 4D));
return new ColorDrawable(Color.argb(j, 0, 0, 0));}
最後に、先ほど作成したウィンドウマネージャにビューを追加します。
windowManager.addView(view, layoutParams);
注:あなたが画面上にオーバーレイを築くためにSYSTEM_ALERT_WINDOW
許可が必要です。
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
これはテスト済みであり、動作します。あなたが立ち往生したら教えてください。
この[質問]への完全な回答を投稿できますかhttp://stackoverflow.com/questions/22748031/create-a-simple-screen-filter)例を使用すると非常に高く評価されます – noobProgrammer
私は同じ問題に直面しています。私もこの質問を投稿しているhttp://stackoverflow.com/questions/2222146/control-screen-brightness-in-android-using-background-service。私はこの問題を解決することができました。 Uはポストで正しい方法を見ることができます。 –
このリンクを試してみてください。http://android-er.blogspot.com/2011/02/change-android-screen-brightness.html –