Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this. I can't guarantee that it will work properly on all devices.</p> <pre><code>private ITelephony getTelephonyService() { try { TelephonyManager oTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); Method mGetITelephony = oTelephonyManager.getClass().getDeclaredMethod("getITelephony", new Class[] {}); mGetITelephony.setAccessible(true); return (ITelephony) mGetITelephony.invoke(oTelephonyManager, new Object[] {}); } catch (Exception e) { return null; } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { boolean retval = getTelephonyService().setRadio(false); Log.v("Radio", "SetRadio : " + retval); } catch (Exception e) { Log.v("Radio", Log.getStackTraceString(e)); } } </code></pre> <p>You will also need the ITelephony.aidl file. Create a package <code>com.android.internal.telephony</code> under your project's src folder and create a file <code>ITelephony.aidl</code> in it with the following content:</p> <pre><code>/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import android.os.Bundle; import java.util.List; /** * Interface used to interact with the phone. Mostly this is used by the * TelephonyManager class. A few places are still using this directly. * Please clean them up if possible and use TelephonyManager insteadl. * * {@hide} */ interface ITelephony { /** * Check to see if the radio is on or not. * @return returns true if the radio is on. */ boolean isRadioOn(); /** * Toggles the radio on or off. */ void toggleRadioOnOff(); /** * Set the radio to on or off */ boolean setRadio(boolean turnOn); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload