[Android General] LittlEvil:
Hello Guys I am Back with guide.Generally i am going to show how to control mod from other app i think you have seen in rom etc when we click show toggle it show toggle but when we click on disable toggle it disable toggle what is that how to do that let gonna do.Basically you should have basic android programming knowledge and how to make java into smali how to put it into the apk and debug.This guide i created because of [MENTION=5981481]ShadeSK[/MENTION] request so i created otherwise i wont . Okay Lets start.

Instruction

First of all create android project in your ide . Then make class which extends PreferenceActivity then make xml name setting then addPreferencesFromResource(id_to_xml) then make checkbox in the xml then populate the checkbox from the java class you can populate by

CheckBoxPreference mClockColor = (ColorPickerPreference) findPreference(" in the xml which you have declared as key");

then make class FireSender and add content

package com.androidfire;

import android.content.Context;
import android.content.Intent;

public class FireSender {
public static void mailTo(Context c,String id,boolean value) {
Intent intent = new Intent();
intent.setAction(id);
intent.putExtra(id,value);
c.sendBroadcast(intent);
}
}

then make another class named FireObserver add content

/**
* AndroidFire 2015
* All files of AndroidFire are free to use reproduce utilise
* fork re use change package name and class name as you want
* (( but )) please give credit
*/
package com.androidfire;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import static android.content.SharedPreferences.*;

public class FireObserver {

/**
* Use this class as brain don't touch any file maybe FC or etc
*/

// Context must be passed other wise cant do anything
private Context mContext;
// Specific url for class
private String mSPECIFIC_URL;
// Required to get data from this
public BroadcastReceiver mBroadcastReceiver;

// Need to save data so we need it
public SharedPreferences mSPHelper;

// This is it status of that thing
private boolean mStatus;

/**
* Passed these parameter to this class otherwise it will wont work
* [MENTION=955119]param[/MENTION] context set specific context
* [MENTION=955119]param[/MENTION] Specific_url this means you have to set id like com.bla (This is most important thing
* you have to add unique for one mod)
* [MENTION=955119]param[/MENTION] observerListener default value is this and implement it on the class
*/
public FireObserver(Context context,String Specific_url, final ObserverListener observerListener) {

setContext(context);

setSPECIFIC_URL(Specific_url);

mSPHelper = getContext().getSharedPreferences("AndroidFire",Context.MODE_PRIVATE);
mStatus = mSPHelper.getBoolean(Specific_url, true);
mSPHelper.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
[MENTION=439709]override[/MENTION]
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
mStatus = sharedPreferences.getBoolean(getSPECIFIC_URL(), true);
if (mStatus) {
observerListener.onEnabled();
}
else if (!mStatus) {
observerListener.onDisabled();
}
}
});

if (mStatus) {
observerListener.onEnabled();
}
else if (!mStatus) {
observerListener.onDisabled();
}

mBroadcastReceiver = new BroadcastReceiver() {
[MENTION=439709]override[/MENTION]
public void onReceive(Context context, Intent intent) {
boolean status = intent.getBooleanExtra(getSPECIFIC_URL(),true);
mStatus = status;
SharedPreferences.Editor ed = mSPHelper.edit();
ed.putBoolean(getSPECIFIC_URL(),status);
ed.apply();
}

};

context.registerReceiver(mBroadcastReceiver,new IntentFilter(Specific_url));

}

public Context getContext() {
return mContext;
}

public void setContext(Context mContext) {
this.mContext = mContext;
}

public String getSPECIFIC_URL() {
return mSPECIFIC_URL;
}

public void setSPECIFIC_URL(String mSPECIFIC_URL) {
this.mSPECIFIC_URL = mSPECIFIC_URL;
}

public interface ObserverListener {
public void onEnabled();
public void onDisabled();
}
}

then in the mod class that you have prepare go to that class as in this i have TestText

then declare FireObserver as

FireObserver fireObserver = new FireObserver(getContext(),"com.SimpleText",this);

getContext(); means you have to pass context

then com.SimpleText means the url you have to register according mod like com.androidfire.CLOCK_ON_STATUSBAR etc

this means you have to implement FireObserver.ObserverListener into class on the method onEnabled declare that what you want to do if the it is checked on the other hand onDisbaled is opposite in case of my i want change the visibility.

then go the main class where you have extend PreferanceActivity then

add

if (Cb.isChecked()) {
FireSender.mailTo(getApplicationContext(),"com.SimpleText",true);
}
else {
FireSender.mailTo(getApplicationContext(),"com.SimpleText",false);
}

then compile it and attached to pulled out three smali mod one , FireSender and FireObserver then attached to the apk where you want to add then install apk that you have made and run the app you have modify and check does it work if does not work give me the source i will find your error