How can I sign my application with the system signature key?

后端 未结 2 1402
自闭症患者
自闭症患者 2020-11-30 09:18

I need to create a Robotium application that would use Settings application to turn ON/OFF WIFi from menu Settings->Wireless & networks->Wi-Fi. I managed to find some sa

相关标签:
2条回答
  • 2020-11-30 09:52

    I was having the same problem.. There are some permissions that only system apps are allowed to have . I was trying to access the adb shell dumpsys commands from my application with the permissions android.permission.DUMP .

    The solution to this is ...

    In the Android manifest file of your project add the following line in the manifest tag

    android:sharedUserId="android.uid.system"
    

    You need to have two signature keys present in the code that is used to build the binary.

    platform.x509.pem

    platform.pk8

    that is present in the

    android/build/target/product/security

    Download a tool from the net i.e.

    signapk.jar

    From the eclipse export your unsigned apk. by right click on the project from the android tools. Keep all the things i.e. keys , unsigned apk, and signapk.jar in a folder. Run the following Command

    java -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk
    

    unsigned apk is the name of your apk and signed apk is the new name you want . After this just install your signed app in the phone with the command

    adb shell install signed.apk
    
    0 讨论(0)
  • 2020-11-30 09:52

    The best way to enable wifi from your application would be to use the WifiManager.

    WifiManager wManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
    
    if(!wManager.isWifiEnabled() && wManager.getWifiState() != WifiManager.WIFI_STATE_ENABLING)
        wManager.setWifiEnabled(true);
    

    Note: You also have to add the following permissions to your manifest

    <uses-permission android:name="android.permissions.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permissions.CHANGE_WIFI_STATE" />
    
    0 讨论(0)
提交回复
热议问题