Editing "Regulatory Information" to display a Japanese 技適マーク (Certification mark) - General Questions and Answers

Editing "Regulatory Information" to display a Japanese 技適マーク (Certification mark)
Hello XDA forums,
I'm fairly new to Android, and did a lot of googling and searching of the forums, but couldn't find an answer.
In short, due to old outdated laws in Japan (please search for 技適マーク as i can't post outside links yet...)
any wireless device not displaying this mark is not allowed to have sim cards or do any sort of wireless transmission.
Normally not a problem, but my Asus Zenfone 2 doesn't have the mark, even though Zenfone 2 is cleared by their equivalent of the FCC, and phones sold in Japan have the mark.
I'm messing around with build.prop editor, and attemping to locate where the damn pictures are to see if i can just change em out, or edit a line or two to display that mark.
Anyone want to help me out?
i'd be very grateful!

Code:
/*
* Copyright (C) 2013 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
*
*
*
* 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.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.TextView;
/**
* {@link Activity} that displays regulatory information for the "Regulatory information"
* preference item, and when "*#07#" is dialed on the Phone keypad. To enable this feature,
* set the "config_show_regulatory_info" boolean to true in a device overlay resource, and in the
* same overlay, either add a drawable named "regulatory_info.png" containing a graphical version
* of the required regulatory info, or add a string resource named "regulatory_info_text" with
* an HTML version of the required information (text will be centered in the dialog).
*/
public class RegulatoryInfoDisplayActivity extends Activity implements
DialogInterface.OnDismissListener {
/**
* Display the regulatory info graphic in a dialog window.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Resources resources = getResources();
if (!resources.getBoolean(R.bool.config_show_regulatory_info)) {
finish(); // no regulatory info to display for this device
}
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.regulatory_information)
.setOnDismissListener(this);
boolean regulatoryInfoDrawableExists;
try {
Drawable d = resources.getDrawable(R.drawable.regulatory_info);
// set to false if the width or height is <= 2
// (missing PNG can return an empty 2x2 pixel Drawable)
regulatoryInfoDrawableExists = (d.getIntrinsicWidth() > 2
&& d.getIntrinsicHeight() > 2);
} catch (Resources.NotFoundException ignored) {
regulatoryInfoDrawableExists = false;
}
CharSequence regulatoryText = resources.getText(R.string.regulatory_info_text);
if (regulatoryInfoDrawableExists) {
builder.setView(getLayoutInflater().inflate(R.layout.regulatory_info, null));
builder.show();
} else if (regulatoryText.length() > 0) {
builder.setMessage(regulatoryText);
AlertDialog dialog = builder.show();
// we have to show the dialog first, or the setGravity() call will throw a NPE
TextView messageText = (TextView) dialog.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
} else {
// neither drawable nor text resource exists, finish activity
finish();
}
}
@Override
public void onDismiss(DialogInterface dialog) {
finish(); // close the activity
}
}
this looks close. it seems to display the "regulatory information"
i wonder if i mess around with it, i can change what it displays?

Related

[Resolved] [Q] Android App Problem (Linking list items to the android market)

Hey guys,
I need some help with my first app.
I cannot post this in the Anddev section because of my low post count, so I apologize that this goes here.
I want to link some list positions to the respective android market pages. My current code looks like this:
Code:
package com.asm.reader;
import java.util.ArrayList;
import java.util.Arrays;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
public class TitlesActivity extends ListActivity {
/** Called when the activity is first created. */
String[] links = {
"Get Full Version", "Get Reading Sample 2", "Get Reading Sample 3", "Get Reading Sample 4", "Get Reading Sample 5",
"Get Story 2", "Get Story 3", "Get Story 4", "Get Story 5"};
private ArrayAdapter<String> adapter;
private String selectedItem;
private final Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OnItemClickListener itemListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int position,
long arg3) {
}
};
ArrayList<String> list = new ArrayList<String>(Arrays.asList(links));
adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_list_item_1,
list);
setListAdapter(adapter);
getListView().setOnItemClickListener(itemListener);
}
}
The dev guide says I have to do this:
Code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);
But how do I set it with the right position?
Thanks a lot in advance, I hope you guys can help me out a little bit.
-----
edit: i got it
Please post how you did it!

[Q] Building Nyandroid + platlogo into an app

I've been hacking away at a few java files (PlatlogoActivity.java, Nyandroid.java) extracted from AOSP ICS source in Eclipse. There were some errors that I was able to solve (some funky ones about vibration, but I just removed all code related to vibration instead) but now there is one error, that no matter what, I can't solve. In the Nyandroid.java, I keep on getting the error "Cannot cast from TimeAnimator to ValueAnimator" on the line "((ValueAnimator) mAnim).cancel();" no matter how much I try changing that line (for example to "mAnim.cancel();") based on some custom ROM sources that I've looked through, and some stackoverflow questions. The app source is attached to this post, and below you can find the Nyandroid.java if you're willing to help - please do. I want to get into app developing for Android, or atleast understanding some java. I managed to port the Gingerbread platlogo for all Android versions but it's obviously much easier to do because it's just one still image and a toast. But I really want to port the ICS Nyandroid easter egg, for some practice with java.
/*);
* Copyright (C) 2011 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.nyandroid;
import android.animation.AnimatorSet;
import android.animation.PropertyValuesHolder;
import android.animation.ObjectAnimator;
import android.animation.TimeAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import java.util.HashMap;
import java.util.Random;
public class Nyandroid extends Activity {
final static boolean DEBUG = false;
public static class Board extends FrameLayout
{
public static final boolean FIXED_STARS = true;
public static final int NUM_CATS = 20;
static Random sRNG = new Random();
static float lerp(float a, float b, float f) {
return (b-a)*f + a;
}
static float randfrange(float a, float b) {
return lerp(a, b, sRNG.nextFloat());
}
static int randsign() {
return sRNG.nextBoolean() ? 1 : -1;
}
static <E> E pick(E[] array) {
if (array.length == 0) return null;
return array[sRNG.nextInt(array.length)];
}
public class FlyingCat extends ImageView {
public static final float VMAX = 1000.0f;
public static final float VMIN = 100.0f;
public float v, vr;
public float dist;
public float z;
public ComponentName component;
public FlyingCat(Context context, AttributeSet as) {
super(context, as);
setImageResource(R.drawable.nyandroid_anim); // @@@
if (DEBUG) setBackgroundColor(0x80FF0000);
}
public String toString() {
return String.format("<cat (%.1f, %.1f) (%d x %d)>",
getX(), getY(), getWidth(), getHeight());
}
public void reset() {
final float scale = lerp(0.1f,2f,z);
setScaleX(scale); setScaleY(scale);
setX(-scale*getWidth()+1);
setY(randfrange(0, Board.this.getHeight()-scale*getHeight()));
v = lerp(VMIN, VMAX, z);
dist = 0;
// android.util.Log.d("Nyandroid", "reset cat: " + this);
}
public void update(float dt) {
dist += v * dt;
setX(getX() + v * dt);
}
}
TimeAnimator mAnim;
public Board(Context context, AttributeSet as) {
super(context, as);
setLayerType(View.LAYER_TYPE_HARDWARE, null);
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
setBackgroundColor(0xFF003366);
}
private void reset() {
// android.util.Log.d("Nyandroid", "board reset");
removeAllViews();
final ViewGroup.LayoutParams wrap = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
if (FIXED_STARS) {
for(int i=0; i<20; i++) {
ImageView fixedStar = new ImageView(getContext(), null);
if (DEBUG) fixedStar.setBackgroundColor(0x8000FF80);
fixedStar.setImageResource(R.drawable.star_anim); // @@@
addView(fixedStar, wrap);
final float scale = randfrange(0.1f, 1f);
fixedStar.setScaleX(scale); fixedStar.setScaleY(scale);
fixedStar.setX(randfrange(0, getWidth()));
fixedStar.setY(randfrange(0, getHeight()));
final AnimationDrawable anim = (AnimationDrawable) fixedStar.getDrawable();
postDelayed(new Runnable() {
public void run() {
anim.start();
}}, (int) randfrange(0, 1000));
}
}
for(int i=0; i<NUM_CATS; i++) {
FlyingCat nv = new FlyingCat(getContext(), null);
addView(nv, wrap);
nv.z = ((float)i/NUM_CATS);
nv.z *= nv.z;
nv.reset();
nv.setX(randfrange(0,Board.this.getWidth()));
final AnimationDrawable anim = (AnimationDrawable) nv.getDrawable();
postDelayed(new Runnable() {
public void run() {
anim.start();
}}, (int) randfrange(0, 1000));
}
if (mAnim != null) {
((ValueAnimator) mAnim).cancel();
}
mAnim = new TimeAnimator();
mAnim.setTimeListener(new TimeAnimator.TimeListener() {
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
// setRotation(totalTime * 0.01f); // not as cool as you would think
// android.util.Log.d("Nyandroid", "t=" + totalTime);
for (int i=0; i<getChildCount(); i++) {
View v = getChildAt(i);
if (!(v instanceof FlyingCat)) continue;
FlyingCat nv = (FlyingCat) v;
nv.update(deltaTime / 1000f);
final float catWidth = nv.getWidth() * nv.getScaleX();
final float catHeight = nv.getHeight() * nv.getScaleY();
if ( nv.getX() + catWidth < -2
|| nv.getX() > getWidth() + 2
|| nv.getY() + catHeight < -2
|| nv.getY() > getHeight() + 2)
{
nv.reset();
}
}
}
});
}
@Override
protected void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w,h,oldw,oldh);
// android.util.Log.d("Nyandroid", "resized: " + w + "x" + h);
post(new Runnable() { public void run() {
reset();
mAnim.start();
} });
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mAnim.cancel();
}
@Override
public boolean isOpaque() {
return true;
}
}
private Board mBoard;
@Override
public void onStart() {
super.onStart();
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
);
}
@Override
public void onResume() {
super.onResume();
mBoard = new Board(this, null);
setContentView(mBoard);
mBoard.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int vis) {
if (0 == (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) {
Nyandroid.this.finish();
}
}
});
}
@Override
public void onUserInteraction() {
// android.util.Log.d("Nyandroid", "finishing on user interaction");
finish();
}
}
Click to expand...
Click to collapse

[GUIDE] AutomateIt Plug-in Development

Prerequisite
Don't know what is AutomateIt ? Read more on this thread.
What is AutomateIt Plugin ?
Plugins are applications that by installing them, you add new actions and triggers that you can use within AutomateIt. Sounds easy, right ?
Each plugin can provide additional triggers and actions that extend the capabilities of AutomateIt, so you can focus on the functionality and take advantage of the AutomateIt platform to connect each trigger or action with existing capabilities of AutomateIt or with other plugins.
More details and a list of available plugins are available on the app website.
Getting started
Although developing a plugin is super-easy and requires only several simple steps, you are deeply encouraged to read the full documentation on the app website.
To summarize it for you, here are the steps you need to follow when developing a new plugin:
Download AutomateIt Plugin SDK
Setup your environment
Develop your plugin
Test your plugin
Setting up your environment after downloading the plugin SDK is done by adding a single dependency needs to be added to your build.gradle file:
Code:
compile 'com.automateitapp:automateit.plugin.sdk:1.0.3'
Creating a new plugin action or trigger is done by implementing a class that extends either PluginAction or PluginTrigger in your plugin project that references the AutomateItPluginLibrary.
Each of these abstract classes requires a set of simple functions to be implemented that provide metadata for the action or trigger (such as title, description, icons and parameters) and the functionality of the action or trigger. See sample code below for an action that shows a Toast message.
a complete sample app is available as a git repo that can be cloned from here.
When the plugin app is installed on a user device, it communicates with AutomateIt so that the plugin actions and triggers become available within AutomateIt.
Additional Documentation
AutomateIt Plugin Developer Guide
AutomateIt Plugin SDK Reference
Looking forward to seeing some awesome plugins !
Sample Action Code
Code:
package com.smarterapps.demoplugin.actions;
import java.util.List;
import android.content.Context;
import android.widget.Toast;
import com.smarterapps.automateitplugin.sdk.PluginDataFieldCollection;
import com.smarterapps.automateitplugin.sdk.PluginValidationResult;
import com.smarterapps.automateitplugin.sdk.RequiredApp;
import com.smarterapps.automateitplugin.sdk.fields.PluginDataFieldBoolean;
import com.smarterapps.automateitplugin.sdk.fields.PluginDataFieldString;
import com.smarterapps.demoplugin.R;
public class Action1 extends com.smarterapps.automateitplugin.sdk.PluginAction
{
private static final int FIELD_ID_TEXT_TO_SHOW = 1;
private static final int FIELD_ID_DURATION_LONG = 2;
@Override
public String getActionTitle(Context context)
{
return context.getString(R.string.action1_title);
}
@Override
public String getActionDescription(Context context)
{
return context.getString(R.string.action1_default_description);
}
@Override
public String getActionDescription(Context context, PluginDataFieldCollection data)
{
if (null != data)
{
String msgText = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();
boolean durationLong = (Boolean) data.getFieldById(FIELD_ID_DURATION_LONG).getValue();
int toastDurationStringId = durationLong ? R.string.duration_long: R.string.duration_short;
return context.getString(R.string.action1_description,
context.getString(toastDurationStringId),
msgText);
}
return getActionDescription(context);
}
@Override
public int getActionIconResourceId()
{
return R.drawable.ic_action1;
}
@Override
public int getActionSmallIconResourceId()
{
return R.drawable.ic_action1_small;
}
@Override
public PluginDataFieldCollection getActionFields(Context context)
{
PluginDataFieldCollection retval = new PluginDataFieldCollection();
retval.add(new PluginDataFieldBoolean(
FIELD_ID_DURATION_LONG,
context.getString(R.string.action1_field_duration_title),
context.getString(R.string.action1_field_duration_description),
true));
retval.add(new PluginDataFieldString(
FIELD_ID_TEXT_TO_SHOW,
context.getString(R.string.action1_field_msg_title),
context.getString(R.string.action1_field_msg_description),
""));
return retval;
}
@Override
public void doAction(Context context, PluginDataFieldCollection data)
{
boolean durationLong = (Boolean) data.getFieldById(FIELD_ID_DURATION_LONG).getValue();
int toastDuration = durationLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
String toastMsg = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();
Toast.makeText(context, toastMsg, toastDuration).show();
}
@Override
public PluginValidationResult validateData(Context context, PluginDataFieldCollection data)
{
// Validate action1
String toastMsg = (String) data.getFieldById(FIELD_ID_TEXT_TO_SHOW).getValue();
if (null == toastMsg || toastMsg.trim().length() == 0)
{
return new PluginValidationResult(false, "Toast message can't be empty");
}
return PluginValidationResult.getValidResult();
}
@Override
public List<RequiredApp> getRequiredApps()
{
return null;
}
}
AutomateIt Plugin SDK has been updated so it is now even easier to integrate actions and triggers into your apps, or build a brand new plugin.
It requires a single dependency in your build.gradle file and the rest is up to you!
Sample app is available as a git repo on bitbucket.org:
https://bitbucket.org/AutomateIt/automateit-plugin-demo
(Instructions were updated on the developer website and this post).

Google Play Game Services in libgdx

The article was written in the course of the game's development CLEAR SKY 2
The first part here!
Code
In the main Activity implement two interfaces GameHelperListener, ActionResolver:
public class MainActivity extends AndroidApplication implements GameHelperListener, ActionResolver
GameHelperListener interface is as follows:
Code:
public interface GameHelperListener {
/ **
* Called when an attempt to login. This method can show
* User button «Sign-in» for manual entry
* /
void onSignInFailed ();
/ ** Called when a successful login attempt * /
void onSignInSucceeded ();
}
Interface ActionResolver create ourselves. He needed to call the platform-dependent code. This technique is described in the official wiki libgdx. An example of the interface:
Code:
public interface ActionResolver {
/ ** Check the status of the user input * /
public boolean getSignedInGPGS ();
/ ** Log * /
public void loginGPGS ();
/ ** Send the result in the high score table * /
public void submitScoreGPGS (int score);
/ **
* Unlock achievement
*
*param AchievementId
* ID achievements. Taken from the file games-ids.xml
* /
public void unlockAchievementGPGS (String achievementId);
/ ** Show Activity records to the table * /
public void getLeaderboardGPGS ();
/ ** Show Activity achievements * /
public void getAchievementsGPGS ();
}
Example code main Activity:
Code:
public class MainActivity extends AndroidApplication implements
GameHelperListener, ActionResolver {
// Assistant to work with gaming services
private GameHelper gameHelper;
// Class of our games
private TestGame game;
Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
// CLIENT_ALL instruct you on the use of the API all customers
gameHelper = new GameHelper (this, GameHelper.CLIENT_ALL);
// Disable automatic login when starting the game
gameHelper.setConnectOnStart (false);
gameHelper.enableDebugLog (true);
// From turning off the screen without the use of additional
// Permits (less than permissions - more confidence in the application)
getWindow (). addFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Input parameter this is ActionResolver. Allows you to call from
// Game loop platform-specific methods GPGS
game = new TestGame (this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration ();
initialize (game, config);
gameHelper.setup (this);
}
// Methods gameHelper'a: onStart (), onStop () are called to work correctly
// GPGS in the lifecycle of android-app
Override
protected void onStart () {
super.onStart ();
gameHelper.onStart (this);
}
Override
protected void onStop () {
super.onStop ();
gameHelper.onStop ();
}
Override
protected void onDestroy () {
super.onDestroy ();
}
Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
super.onActivityResult (requestCode, resultCode, data);
// Here gameHelper decides to connect, or reconnect
// Disconnected from the game services, depending on the result code
// Activity
gameHelper.onActivityResult (requestCode, resultCode, data);
}
Override
public boolean getSignedInGPGS () {
// Connection status
return gameHelper.isSignedIn ();
}
Override
public void loginGPGS () {
try {
runOnUiThread (new Runnable () {
Override
public void run () {
// Initiate user entry. Can be called a dialogue
// Login. Performed in UI-stream
gameHelper.beginUserInitiatedSignIn ();
}
});
} Catch (Exception e) {
e.printStackTrace ();
}
}
Override
public void submitScoreGPGS (int score) {
// Send game points to a specific table records with ID
// "HgkIr62KmoQJEAIQAQ"
Games.Leaderboards.submitScore (gameHelper.getApiClient (),
"HgkIr62KmoQJEAIQAQ", score);
}
Override
public void unlockAchievementGPGS (String achievementId) {
// Open achievement with ID achievementId
Games.Achievements.unlock (gameHelper.getApiClient (), achievementId);
}
Override
public void getLeaderboardGPGS () {
Activity // call for all registered tables records. as
Activity // can call for a specific table
startActivityForResult (
Games.Leaderboards.getAllLeaderboardsIntent (gameHelper
.getApiClient ()), 100);
}
Override
public void getAchievementsGPGS () {
// Call Activity achievements
startActivityForResult (
Games.Achievements.getAchievementsIntent (gameHelper
.getApiClient ()), 101);
}
Override
public void onSignInSucceeded () {
}
Override
public void onSignInFailed () {
}
}
Suppose we have in the game provided the achievement - to collect 1 million. Player points, the code implementing it would look like this:
Code:
public static void checkTotalPoints (int points) {
ActionResolver res = getActionResolver ();
if (! res.getSignedInGPGS ()) {
return;
}
if (points> = 1000000) {
res.unlockAchievementGPGS ("HgkIr62KmoQJEAIQGA");
}
}
Same thing with a table of records, only even easier: you just need to call the submitScoreGPGS (int score) interface ActionResolver.
PS To test gaming services need to export apk-file with the same certificate as in the developer console. Just need to add accounts testers in the console. Changes in gaming services come into effect after a while.
Google Play Clear Sky 2
Long second part released!
sources used
developers.google.com/games/services/android/quickstart
developer.android.com/intl/ru/google/play-services/setup.html
github.com/libgdx/libgdx/wiki
Please don't add the &hl=ru parameter to your Play Store links - then it is in Russian for all users. Without it, native language is used.

[GUIDE] How to control mod from other app

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 @ShadeSK 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
HTML:
CheckBoxPreference mClockColor = (ColorPickerPreference) findPreference(" in the xml which you have declared as key");
then make class FireSender and add content
HTML:
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
HTML:
/**
* 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
* [user=955119]@param[/user] context set specific context
* [user=955119]@param[/user] 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)
* [user=955119]@param[/user] 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() {
[user=439709]@override[/user]
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() {
[user=439709]@override[/user]
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
HTML:
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
HTML:
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
AndroidFire said:
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 @ShadeSK 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
HTML:
CheckBoxPreference mClockColor = (ColorPickerPreference) findPreference(" in the xml which you have declared as key");
then make class FireSender and add content
HTML:
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
HTML:
/**
* 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
* [user=955119]@param[/user] context set specific context
* [user=955119]@param[/user] 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)
* [user=955119]@param[/user] 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() {
[user=439709]@override[/user]
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() {
[user=439709]@override[/user]
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
HTML:
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
HTML:
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
Click to expand...
Click to collapse
No words Bro Thanks alot

Categories

Resources