android 针对单个app修改分辨率

时间:2024-10-08 09:46:12

因为设备分辨率是480x640  横屏设备,但是微信没有该横屏分辨率

在进入微信这些app的时候修改系统分辨率为1080x1920 退出这些app的时候还原系统原来分辨率

frameworks/base/core/java/android/app/

 public void onWindowFocusChanged(boolean hasFocus) {
 try {
    if(hasFocus){
    			
        if("".equals(getPackageName())){
                Intent intent=new Intent("");
                ("resolution", "1080x1920");
                ("");
                startService(intent);
          }else {
                Intent intent=new  Intent("");
                ("resolution", "480x640");
                ("");
                startService(intent);
            	}	
    	 }
 } catch (Exception e) {
	  ();
 }
    	

packages/apps/Settings/

<service android:name="" android:exported="true">

<intent-filter>

<action android:name=""/>

</intent-filter>

</service>

packages/apps/Settings/src/com/android/settings/

package ;

import ;
import ;
import ;
import ;
public class UpdateResolutionService extends Service {

	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}
	@Override
	public void onCreate() {
		();
	}
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		try {
			String resolution=("resolution");
			int w=480;
			int h=640;
			if(resolution!=null){
				String[]temp=("x");
				w=(temp[0]);
				h=(temp[1]);
			}
         mWm =       ((Context.WINDOW_SERVICE));        	 
        	(.DEFAULT_DISPLAY, w, h);
		} catch (Exception e) {
			();
		}
		return (intent, flags, startId);
	}
}