[Q] how to make a select all check box - General Questions and Answers

hi, i am trying to make a check all check box and i didnt know how to do that, i cant really explain it that well so i will just show you the code:
xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<CheckBox
android:id="@+id/cbAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="25"
android:text="Select All"
android:checked="true" />
<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true" />
<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true" />
<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true" />
<CheckBox
android:id="@+id/cb4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true" />
<CheckBox
android:id="@+id/cb5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true" />
java:
Code:
CheckBox cb1, cb2, cb3, cb4, cb5, cbAll;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cb1 = (CheckBox) findViewById(R.id.cb1);
cb2 = (CheckBox) findViewById(R.id.cb2);
cb3 = (CheckBox) findViewById(R.id.cb3);
cb4 = (CheckBox) findViewById(R.id.cb4);
cb5 = (CheckBox) findViewById(R.id.cb5);
cbAll = (CheckBox) findViewById(R.id.cbAll);
cbAll.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (cbAll.setChecked(true)){
cb1.setChecked(true);
cb2.setChecked(true);
cb3.setChecked(true);
cb4.setChecked(true);
cb5.setChecked(true);
}else{
cb1.setChecked(false);
cb2.setChecked(false);
cb3.setChecked(false);
cb4.setChecked(false);
cb5.setChecked(false);
}
}
});
what i am asking is, is this part right, and if not can you tell me the right way to do it please:
Code:
cbAll.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (cbAll.setChecked(true)){
cb1.setChecked(true);
cb2.setChecked(true);
cb3.setChecked(true);
cb4.setChecked(true);
cb5.setChecked(true);
}else{
cb1.setChecked(false);
cb2.setChecked(false);
cb3.setChecked(false);
cb4.setChecked(false);
cb5.setChecked(false);
}
}
});
thank you.

Your problem is this line...
Code:
if (cbAll.setChecked(true)) {
...
You're setting the value of the cbAll checkbox, not getting it. You should use...
Code:
if (cbAll.isChecked()) {
...

Archer said:
Your problem is this line...
Code:
if (cbAll.setChecked(true)) {
...
You're setting the value of the cbAll checkbox, not getting it. You should use...
Code:
if (cbAll.isChecked()) {
...
Click to expand...
Click to collapse
Thank you!
I also have one more question, how can you have a button that when its clicked it brings me to another activity? Like if you click the button it goes to com.example.example.Example. How would I do that?

steineronie said:
Thank you!
I also have one more question, how can you have a button that when its clicked it brings me to another activity? Like if you click the button it goes to com.example.example.Example. How would I do that?
Click to expand...
Click to collapse
No worries mate. Have a look here...
http://www.dotnetexpertsforum.com/how-to-open-a-new-activity-from-button-click-in-android-t1322.html
I'm not being dismissive when I say this, like I often am with people on xda who ask how to do things that are heavily documented, but googling is a VERY useful tool for development work. I use it heavily on a daily basis. You just need to get good at searching with it and there's very little you can't find.
Eg. for your query I just googled for android button open new activity.
I'm happy to help, as I'm sure others on here are also happy to help, but sometimes Googling will get you a quicker answer.
Good luck mate
Edit: Forgot to mention, there's also a dedicated Android dev forum on here...
http://forum.xda-developers.com/forumdisplay.php?f=524

Archer said:
No worries mate. Have a look here...
http://www.dotnetexpertsforum.com/how-to-open-a-new-activity-from-button-click-in-android-t1322.html
I'm not being dismissive when I say this, like I often am with people on xda who ask how to do things that are heavily documented, but googling is a VERY useful tool for development work. I use it heavily on a daily basis. You just need to get good at searching with it and there's very little you can't find.
Eg. for your query I just googled for android button open new activity.
I'm happy to help, as I'm sure others on here are also happy to help, but sometimes Googling will get you a quicker answer
.
Good luck mate
Edit: Forgot to mention, there's also a dedicated Android dev forum on here...
http://forum.xda-developers.com/forumdisplay.php?f=524
Click to expand...
Click to collapse
Sorry for not looking on google, i will next time, and thank you again.

steineronie said:
Sorry for not looking on google, i will next time, and thank you again.
Click to expand...
Click to collapse
Don't worry about it mate - glad to help.

Related

[APP] Shark for Root + SharkReader

There were AndroShark, tool for capturing traffic on Android. But there were no newer releases and it seems that original developer dropped project. I liked this tool and used it a lot. But it was set to expire... So there was no simple capture tools available... http://forum.xda-developers.com/showthread.php?t=675206 is home of AndroShark.
So I made Shark for Root, alternative for AndroShark. Some people asked for possibility to see packets on phone, and for that purpose SharkReader has created (first, "quick and dirty" release).
Shark for Root
With tcpdump http://swapper.n3o.lv/lv.n3o.shark_1.0.2.apk
Native http://swapper.n3o.lv/lv.n3o.sharknative_1.0.2.apk
SharkReader - unstable...
(note - run Shark Updater to get traffic analysator)
http://swapper.n3o.lv/lv.n3o.sharkreader_0.1.6.apk
Older versions http://swapper.n3o.lv/
EPIC
Thank you!
If you press stop, it doesn't truly stop. tcpdump seems like it is still going in the background. The file will continue getting larger and larger even though it has been told to stop capturing.
Running CyanogenMod 6 RC1.
Thank you.
Far as I can tell it's working good, Thanks for the reader, helps a lot, I can see this program becoming a portable wireshark app for android, keep up the great work and thank you.
Awesome start!! Thanks!
Sent from my Nexus One using XDA App
does this program work with rooted x10? i clcik on start and all i see is "not found".. my parameters are empty is this also correct ?
thanks
cool app! thanks!
duffy1807 said:
does this program work with rooted x10? i clcik on start and all i see is "not found".. my parameters are empty is this also correct ?
thanks
Click to expand...
Click to collapse
Default parameters are -vv -s 0
Can You send me more information about Your error?
Could someone tell about using different parameters or point me to some website where i could study these?(now i got the defaults)
And when i open Shark reader i see many "RAW Packet" but i cant get any information from them, just "Packet #number".
.pcap files are fine when i open them with Wireshark.
At the bottom i see this: -NULL , what else i can use here and how it effects?
Interesting app, keep up the good work!
A changelog would be nice.
I also can not run Shark on my X10. I get the error 'reloc_library [1215]: cannot locate _aeabi_fdiv CANNOT LINK EXECUTABLE
Sent from my X10a using XDA App
acips said:
Could someone tell about using different parameters or point me to some website where i could study these?(now i got the defaults)
And when i open Shark reader i see many "RAW Packet" but i cant get any information from them, just "Packet #number".
.pcap files are fine when i open them with Wireshark.
At the bottom i see this: -NULL , what else i can use here and how it effects?
Interesting app, keep up the good work!
Click to expand...
Click to collapse
Hello!
For Shark for Root parameters look at some examples/manuals about tcpdump. F.e. http://www.cs.ucr.edu/~marios/ethereal-tcpdump.pdf
Shark reader marks packets as RAW if it does not recognize it (currently it means it's not tcp/udp packet).
For filters you can use any tag and any tag with - sign. Tags are those in first column. Traffic is tagged by content (signature) and port. Signatures and ports you may update with Shark Updater (included in Shark Reader), but I have too little time to manage all those resources. I'll make this system public for tags submission/port submission, so interested users will be able to add necessary tags.
So, if you want to see only non zero bytes packets with http content, you may use this setting:
Code:
[ ] all [o] none | http -NULL |
Filters are processed in order. So http shows all http packets and -NULL hides those with nulls. First option works as global filter (show all or show none).
Warning! Not all traffic is tagged, so if you miss something, it could mean some tags are incorrectly assigned or skipped.
Hope it helps.
mcampbellsmith said:
I also can not run Shark on my X10. I get the error 'reloc_library [1215]: cannot locate _aeabi_fdiv CANNOT LINK EXECUTABLE
Sent from my X10a using XDA App
Click to expand...
Click to collapse
Which OS version your X10a have? I saw that there are some problems with reloc_library in Android 1.5.
It's Android 1.6 only on the X10
Sent from my X10a using XDA App
i made an spanish thread on my android site, lets see how it works on milestone
thanks!!!!
Can some please explain in lamon terms what this does?
hy there =) can you make a capture filter to msn conversations ? it would be nice =)
I use an app similar called 3G Watchdog (it's free).
Let's you know how much data you've used with a widget too!
slow4g63 said:
I use an app similar called 3G Watchdog (it's free).
Let's you know how much data you've used with a widget too!
Click to expand...
Click to collapse
LOL this is nothing like that my friend.. nothing at all
ex87,
Awesome work bro, life got too busy for me to work more on AndroShark, I really didn't drop it on purpose. But with a busy life, and me still really new at java, it was just too much. I am really glad you picked up the idea and ran with it.
Do you have any plans to opensource it at all (no worries if you dont)? I would like to be a contributor if you do decide to open source it.
I really doubt this is of any use. It was the second java app I ever worked on, and was really just a front end. Below is androshark source code. Like I said, this was my second attempt at writing an app, so please don't laugh If I were to do it today, I would completely change how it worked. /res/raw/sharktap was just tcpdump.
Code:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
/**
* ToDo:
* Check for root
* Check for first run
* Install Binaries on first run
* Check for sdcard mount
* Display file stats
* Name pcap based on file name
* Insert License
* kill sharktap on die
*
* @author jcase
*
*/
public class androshark extends Activity implements /*RadioGroup.OnCheckedChangeListener,*/ Button.OnClickListener {
Button btnStart, btnStop;
RadioButton radAll, rad3g, radWifi; //http://java.dzone.com/articles/google-android-tutorial?page=0,4
RadioGroup grpRadio;
TextView txtStatus, txtFilename, txtFilesize;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnStart = (Button)this.findViewById(R.id.btnStart);
btnStart.setOnClickListener(this);
btnStop = (Button)this.findViewById(R.id.btnStop);
btnStop.setOnClickListener(this);
long epoch = System.currentTimeMillis()/1000;
boolean exists = (new File("/data/data/net.andirc.androshark/files/sharktap")).exists();
if (exists) {
} else {
Process myproc = null;
try
{
try{
String strDirectoy ="/data/data/net.andirc.androshark/files";
new File(strDirectoy).mkdir();
}
finally {}
InputStream ins = getResources().openRawResource(R.raw.sharktap);
int size = ins.available();
byte[] buffer = new byte[size];
ins.read(buffer);
ins.close();
FileOutputStream fos = new FileOutputStream("/data/data/net.andirc.androshark/files/sharktap");
fos.write(buffer);
fos.close();
}
catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}
finally {}
}
boolean exists2 = (new File("/sdcard/androshark/")).exists();
if (exists2) {
} else {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
Process myproc = null;
try
{
myproc = Runtime.getRuntime().exec(new String[] {"su", "-c","chmod 755 /data/data/net.andirc.androshark/files/sharktap && mkdir /sdcard/androshark/"});
new AlertDialog.Builder(this)
.setMessage("This is a beta trial version of androshark and will expire on May 15th 2010. This app can potentially consume a lot of sdcard space, depending on how long you allow it to sniff traffic and how much bandwidth you are using.")
.setPositiveButton("OK", null)
.show();
}
catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}
finally {}
} else {
new AlertDialog.Builder(this)
.setMessage("Error sd01: sdCard not found!")
.setPositiveButton("OK", null)
.show();
}
}
if (epoch >= 1273990849) { // May 15th 2010 1273990849
System.exit(0);
}
}
public void onClick(View v) {
Process myproc = null;
try
{
if (v == btnStart) {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
myproc = Runtime.getRuntime().exec(new String[] {"su", "-c", "kill $(ps | grep sharktap | tr -s ' ' | cut -d ' ' -f2) && /data/data/net.andirc.androshark/files/sharktap -vv -s 0 -w /sdcard/androshark/dump.pcap"});
TextView txtStatus =
(TextView) this.findViewById(R.id.txtStatus);
txtStatus.setText("Status: Running");
TextView txtFilename =
(TextView) this.findViewById(R.id.txtFilename);
txtFilename.setText("Filename: /sdcard/androshark/dump.pcap");
/* int running = 1;
do {
File file = new File("/sdcard/androshark/dump.pcap");
long length = file.length();
TextView txtFilesize =
(TextView) this.findViewById(R.id.txtFilesize);
txtFilesize.setText("File Size: " + length/1024 + "KB");
} while (running <= 1); */
} else {
new AlertDialog.Builder(this)
.setMessage("Error sd02: sdCard not found!")
.setPositiveButton("OK", null)
.show();
}
} else if (v == btnStop) {
myproc = Runtime.getRuntime().exec(new String[] {"su", "-c", "kill $(ps | grep sharktap | tr -s ' ' | cut -d ' ' -f2)"});
myproc.waitFor();
File file = new File("/sdcard/androshark/dump.pcap");
long length = file.length();
TextView txtStatus =
(TextView) this.findViewById(R.id.txtStatus);
txtStatus.setText("Status: Stopped");
TextView txtFilesize =
(TextView) this.findViewById(R.id.txtFilesize);
txtFilesize.setText("File Size: " + length/1024 + "KB");
}
}
catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}
finally {}
}
}
racemepls said:
Can some please explain in lamon terms what this does?
Click to expand...
Click to collapse
shdwknt said:
LOL this is nothing like that my friend.. nothing at all
Click to expand...
Click to collapse
Apparently you know, and still haven't helped those of us who have no idea what this app is for!

When is CM7 coming out?

Well, now that I have your attention, my REAL question is this: Is there a way to make apps like the Amazon marketplace think they're on wifi so I don't get that stupid "you can't download this because it's too big for a cellular network"?
***** please, I pay for unlimited data and I plan to use it.
Sent from my Droid Charge running Infinity Beta
HAHAHA I like your tactics for getting attention.
A while back I made a remark that the only way to get peoples attention in these forums is to ask if CM7 is coming out in the title and then ask the real question in the body.
Well played
Also no, there's no way to trick Amazon
I've actually been working on figuring out a way to do this.
Any app that tries to figure out how it's connected queries the same class in the system called NetworkInfo.class.
There are two methods within NetworkInfo.class that report the network type: getType() and getTypeName(). getType() returns a machine-readable answer, while getTypeName() is human-readable.
Code:
public int getType() {
return mNetworkType;
}
Code:
public String getTypeName() {
switch (mNetworkType) {
case ConnectivityManager.TYPE_WIFI:
return "WIFI";
case ConnectivityManager.TYPE_MOBILE:
return "MOBILE";
default:
return "<invalid>";
}
}
I haven't had the resources (primarily time) to dig that far into things, but if we could figure out a way to inject something between Amazon and the getType() or getTypeName() calls, we could report to it that we're on WiFi regardless of how we're actually connected.
AlexDeGruven said:
I've actually been working on figuring out a way to do this.
Any app that tries to figure out how it's connected queries the same class in the system called NetworkInfo.class.
There are two methods within NetworkInfo.class that report the network type: getType() and getTypeName(). getType() returns a machine-readable answer, while getTypeName() is human-readable.
Code:
public int getType() {
return mNetworkType;
}
Code:
public String getTypeName() {
switch (mNetworkType) {
case ConnectivityManager.TYPE_WIFI:
return "WIFI";
case ConnectivityManager.TYPE_MOBILE:
return "MOBILE";
default:
return "";
}
}
I haven't had the resources (primarily time) to dig that far into things, but if we could figure out a way to inject something between Amazon and the getType() or getTypeName() calls, we could report to it that we're on WiFi regardless of how we're actually connected.
Click to expand...
Click to collapse
Wow, Computer Science II is actually helping me be able to read this. So, what type of object is mNetworkType and where is it defined? We could get it to just return that its on wifi all the time. Also, do you know what Amazon calls? GetType or GetTypeName?
Sent from my Droid Charge running Infinity Beta
Lol. Nicely done with the thread title.
Sent from my mobile office.
AlexDeGruven said:
I've actually been working on figuring out a way to do this.
Any app that tries to figure out how it's connected queries the same class in the system called NetworkInfo.class.
There are two methods within NetworkInfo.class that report the network type: getType() and getTypeName(). getType() returns a machine-readable answer, while getTypeName() is human-readable.
Code:
public int getType() {
return mNetworkType;
}
Code:
public String getTypeName() {
switch (mNetworkType) {
case ConnectivityManager.TYPE_WIFI:
return "WIFI";
case ConnectivityManager.TYPE_MOBILE:
return "MOBILE";
default:
return "<invalid>";
}
}
I haven't had the resources (primarily time) to dig that far into things, but if we could figure out a way to inject something between Amazon and the getType() or getTypeName() calls, we could report to it that we're on WiFi regardless of how we're actually connected.
Click to expand...
Click to collapse
kvswim said:
Wow, Computer Science II is actually helping me be able to read this. So, what type of object is mNetworkType and where is it defined? We could get it to just return that its on wifi all the time. Also, do you know what Amazon calls? GetType or GetTypeName?
Sent from my Droid Charge running Infinity Beta
Click to expand...
Click to collapse
Interesting stuff. There's an iPhone app for jailbroken phones that performs this function on an app-by-app basis. With this code identified, something similar might be possible on Android. I haven't done any Android dev yet, so I don't know how much help I might be. Is there a way to easily (and cheaply) intercept method calls on Android? If so, there might be a way to intercept the getType and getTypeName calls and then modify them on a case-by-case basis so that the call can be diverted to a different function. I'm talking completely theoretical here...I don't know what is offered by the Android SDK.
shrike1978 said:
Interesting stuff. There's an iPhone app for jailbroken phones that performs this function on an app-by-app basis. With this code identified, something similar might be possible on Android. I haven't done any Android dev yet, so I don't know how much help I might be. Is there a way to easily (and cheaply) intercept method calls on Android? If so, there might be a way to intercept the getType and getTypeName calls and then modify them on a case-by-case basis so that the call can be diverted to a different function. I'm talking completely theoretical here...I don't know what is offered by the Android SDK.
Click to expand...
Click to collapse
That was exactly where my investigation has hit the wall at the moment (and then I got busy finishing my basement).
There are a couple of ways to do it, really. Someone could modify the appstore apk to wrap any calls to getType() and getTypeName(), but that would only be on that particular apk. IIRC, the market does it for large apk downloads as well.
Other apps also look at what your network type is.
I'd love to have something that allows me to toggle what the applications see, regardless of the actual state (I'm thinking of things like Verizon's Skype, etc).
The problem with all of this is that NetworkInfo.class is deep in the core OS, so intercepting any calls to it's methods might be rather difficult at best.
Edit: Also - Can we change the thread title now that we know what it's really all about?
ROTFLMFAO! Awesome thread title!
Sent from my SCH-I510 using xda premium
rofl you got me!!! hahahaha... and to answer your question I don't think there is but it'd be nice to know for sure
blazing through on my 4G Droid Charge
In the Amazon Appstore apk, com.amazon.mas.client.framework.net contains a class called NetworkStateManager whose source is:
Code:
package com.amazon.mas.client.framework.net;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class NetworkStateManager
{
private static final int DELAY_DROP_DETECTION = 5000;
private static final String TAG = "NetworkStateManager";
private static final Map<String, WifiManager.WifiLock> wifiLocks = new ConcurrentHashMap();
private final ConnectivityManager connectivityManager;
private final WeakReference<Context> context;
private final Handler delayHandler;
private final List<NetworkStateListener> listeners = new ArrayList();
private boolean networkDropDetected = false;
private NetworkStateReceiver receiver = null;
private boolean wasConnected = false;
private final WifiManager wifiManager;
public NetworkStateManager(Context paramContext)
{
this.context = new WeakReference(paramContext);
this.wifiManager = ((WifiManager)paramContext.getSystemService("wifi"));
this.connectivityManager = ((ConnectivityManager)paramContext.getSystemService("connectivity"));
this.delayHandler = new NetworkStateHandler(null);
if (isNetworkConnected());
for (boolean bool = false; ; bool = true)
{
this.networkDropDetected = bool;
return;
}
}
private WifiManager.WifiLock getWifiLock(String paramString)
{
if (wifiLocks.containsKey(paramString));
for (WifiManager.WifiLock localWifiLock = (WifiManager.WifiLock)wifiLocks.get(paramString); ; localWifiLock = this.wifiManager.createWifiLock(paramString))
return localWifiLock;
}
public boolean acquireWifiLock(String paramString)
{
WifiManager.WifiLock localWifiLock = getWifiLock(paramString);
if (localWifiLock.isHeld())
Log.w("NetworkStateManager", "Wifi lock identified by " + paramString + " already acquired");
for (int i = 0; ; i = 1)
{
return i;
localWifiLock.acquire();
wifiLocks.put(paramString, localWifiLock);
}
}
public void addListener(NetworkStateListener paramNetworkStateListener)
{
if (!this.listeners.contains(paramNetworkStateListener))
this.listeners.add(paramNetworkStateListener);
}
public void clearListeners()
{
this.listeners.clear();
}
public boolean isNetworkConnected()
{
NetworkInfo localNetworkInfo = this.connectivityManager.getActiveNetworkInfo();
if ((localNetworkInfo == null) || (!localNetworkInfo.isConnected()));
for (int i = 0; ; i = 1)
return i;
}
public boolean isNetworkWifi()
{
return this.connectivityManager.getNetworkInfo(1).isConnected();
}
public boolean isWifiLockAcquired(String paramString)
{
WifiManager.WifiLock localWifiLock = getWifiLock(paramString);
if ((localWifiLock != null) && (localWifiLock.isHeld()));
for (int i = 1; ; i = 0)
return i;
}
public void releaseWifiLock(String paramString)
{
WifiManager.WifiLock localWifiLock = getWifiLock(paramString);
if (localWifiLock.isHeld())
{
localWifiLock.release();
if (wifiLocks.containsKey(paramString))
wifiLocks.remove(paramString);
}
while (true)
{
return;
Log.w("NetworkStateManager", "Wifi lock identified by " + paramString + " is not acquired");
}
}
public void removeListener(NetworkStateListener paramNetworkStateListener)
{
this.listeners.remove(paramNetworkStateListener);
}
public void startListening()
{
Context localContext = (Context)this.context.get();
if (this.receiver != null)
Log.w("NetworkStateManager", "Already listening, duplicate call to NetworkStateManager#startListening");
while (true)
{
return;
if (localContext == null)
{
Log.w("NetworkStateManager", "Call to NetworkStateManager#startListening on null context");
continue;
}
this.wasConnected = isNetworkConnected();
IntentFilter localIntentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
this.receiver = new NetworkStateReceiver(null);
localContext.registerReceiver(this.receiver, localIntentFilter);
}
}
public void stopListening()
{
Context localContext = (Context)this.context.get();
if (this.receiver == null)
Log.w("NetworkStateManager", "Not listening, invalid call to NetworkStateManager#stopListening");
while (true)
{
return;
if (localContext == null)
{
Log.w("NetworkStateManager", "Call to NetworkStateManager#stopListening on null context");
continue;
}
localContext.unregisterReceiver(this.receiver);
this.receiver = null;
this.delayHandler.removeMessages(65536);
}
}
private class NetworkStateHandler extends Handler
{
public static final int MSG_NETWORK_DROP = 65536;
private NetworkStateHandler()
{
}
public void handleMessage(Message paramMessage)
{
switch (paramMessage.what)
{
default:
super.handleMessage(paramMessage);
case 65536:
}
while (true)
{
return;
NetworkStateManager.this.wasConnected = false;
NetworkStateManager.this.networkDropDetected = true;
Iterator localIterator = NetworkStateManager.this.listeners.iterator();
while (localIterator.hasNext())
((NetworkStateManager.NetworkStateListener)localIterator.next()).onConnectivityLost();
}
}
}
public static abstract interface NetworkStateListener
{
public abstract void onConnectivityLost();
public abstract void onConnectivityRestored();
}
private class NetworkStateReceiver extends BroadcastReceiver
{
private NetworkStateReceiver()
{
}
public void onReceive(Context paramContext, Intent paramIntent)
{
if ((paramContext == null) || (paramIntent == null) || (!"android.net.conn.CONNECTIVITY_CHANGE".equals(paramIntent.getAction())));
while (true)
{
return;
if (NetworkStateManager.this.isNetworkConnected());
for (int i = 0; ; i = 1)
{
boolean bool = paramIntent.getBooleanExtra("isFailover", false);
if ((i == 0) || (bool) || (!NetworkStateManager.this.wasConnected))
break label99;
Message localMessage = NetworkStateManager.this.delayHandler.obtainMessage(65536);
NetworkStateManager.this.delayHandler.sendMessageDelayed(localMessage, 5000L);
break;
}
label99: if (i != 0)
continue;
if (NetworkStateManager.this.delayHandler.hasMessages(65536))
NetworkStateManager.this.delayHandler.removeMessages(65536);
if (!NetworkStateManager.this.networkDropDetected)
continue;
NetworkStateManager.this.wasConnected = true;
Iterator localIterator = NetworkStateManager.this.listeners.iterator();
while (localIterator.hasNext())
((NetworkStateManager.NetworkStateListener)localIterator.next()).onConnectivityRestored();
}
}
}
}
I'm guessing that making isNetworkWifi() return true would allow for downloads of large files over the cell network. I might repack the APK and post it here if I find the time.
All right, I decompiled the dex file into smali class files, made the change, recompiled, and produced an APK that does not have the wifi restriction, but I'm having problems with signing. I ran a signing tool on the APK, but even after that my phone still fails to install the app (I do have the previous version of the app uninstalled). Has anyone else had experience with this?
substanceD said:
All right, I decompiled the dex file into smali class files, made the change, recompiled, and produced an APK that does not have the wifi restriction, but I'm having problems with signing. I ran a signing tool on the APK, but even after that my phone still fails to install the app (I do have the previous version of the app uninstalled). Has anyone else had experience with this?
Click to expand...
Click to collapse
Care to post it?
Sent from my Droid Charge running Infinity Beta
kvswim said:
Care to post it?
Sent from my Droid Charge running Infinity Beta
Click to expand...
Click to collapse
Yeah, sure. (For anyone else attempting to download this, it will not install in its current form).
Anyone have any luck with the signing?
AlexDeGruven said:
Anyone have any luck with the signing?
Click to expand...
Click to collapse
I'm having troubles too. Is there any way to bypass the sign check? I assume its similar to a CRC or MD5 check.
EDIT: http://developer.android.com/guide/publishing/app-signing.html
What if you saved & signed as a different app name?
Sent from my Droid Charge running Infinity Beta
Bumping
Sent from my Droid Charge running Infinity Beta
Just had an idea. What if we packed it into a ROM as a system APK?
Sent from my Droid Charge running Infinity Beta
Screw CM7. Why was CM8 skipped?! >:[
Sent from my SCH-I510 using xda premium
DirgeExtinction said:
Screw CM7. Why was CM8 skipped?! >:[
Sent from my SCH-I510 using xda premium
Click to expand...
Click to collapse
Great job reading the thread and making a relevant comment.
Aside from that: CM8 would be Honeycomb-based if it were to ever be made, which is unlikely, since it's the one version of Android that's closed-source. ICS will give rise to CM9
AlexDeGruven said:
Great job reading the thread and making a relevant comment.
Aside from that: CM8 would be Honeycomb-based if it were to ever be made, which is unlikely, since it's the one version of Android that's closed-source. ICS will give rise to CM9
Click to expand...
Click to collapse
Why, thank you.
I was bored and just posted that. I knew this thread was about the Amazon appstore(had read some posts from the first page a few days ago).
Sent from my SCH-I510 using xda premium

[Guide} [Basic] App development basics and first android app fully functional

This is basic guide to start to off app development for android..........
This is just a basic guide and not a comprehensive one which covers the whole lot of it but a rather a guide to get a basic simple app of your own running without any issues
Requirements
A bit of java
linux , darwin or a windows 7 machine
internet connection
basic idea of how programming works
sdk with atleast one api installed and configured path
Part 1 setting up everthing and explaining used variables and terms
Now let's get started
[windows}
Download eclipse as any other software and install it by the .exe file and follow the instructions
(linuc macosx )
if you are on a older ditribution of linux the minimum required version of eclipse 3.6 is not supplied via ubuntus main repository ....
so you need to download it from the eclipse official website and install it....
[common}
Installing ADT(Android developer tools) plugin
open up eclipse
Start Eclipse, then select Help > Install New Software.
Click Add, in the top-right corner.
In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
Click OK.
If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
In the next window, you'll see a list of the tools to be downloaded. Click Next.
Read and accept the license agreements, then click Finish.
If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
When the installation completes, restart Eclipse.
Configure the ADT Plugin
Once Eclipse restarts, you must specify the location of your Android SDK directory:
In the "Welcome to Android Development" window that appears, select Use existing SDKs.
Browse and select the location of the Android SDK directory you recently downloaded.
Click Next.
If you haven't encountered any errors, you're done setting up ADT and can continue to Next Steps.
the path to the sdk is case sensitive and absolute so be careful guys....
Now you have virtually everything set up to start building apps
go to file>new>project>android>android application project
something like this will pop up
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
now
the first three fields are yours to choose
now the second part
The build sdk is the sdk that you are targeting in laymans words its like building a building on a certain specific site.....
the minimum required sdk
now if choose this as froyo(api 8) your app will run on froyo os and above and will be compatible with older flavours of android....
once you are done creating a new project hit finish
now you will see something like this
now the calculator is my app name the name that you gave a few minutes ago will be yours...
Now the android is basically divided into three main things
The android manifest
The src folder
The xml
The android manifest basically is a traffic police in lay mans words
it determines which activity comes first when it ends etc...
note:i will be referring the xml to a activty
the src folder contains all of your java
xml's are the skeltel system of android they define the size layout colour or the whole look of your android project....
Note: dont tinker with the gen folder you alone will be responsible for your mistakes
in this tutorial you will be working with only src,res and xml's as i cant dig deeper into it because its a subject too broad to teach....
now lets get started
navigate to res > layout double click on main_activty.xml
below the screen click on activty_main.xml next to graphical layout...
something like this will appear
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
this is the text appearing to you
Note this is auto generated....
now i will explain each line of it with my limited knowledge
HTML:
]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
This is the auto generated refernce by eclipse yours may vary and might not be same as mine
HTML:
android:layout_width="match_parent"
android:layout_height="match_parent"
now you can see that the layout is set to match_parent by deafult
match_parent utilizes the whole screen into your layout...
and observe this guys the
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
the relative layout has started with <relativelayout and ended with > anything code started should be finished up by > or />
both are literally same
now the next junk of code to deal with
HTML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
Textview is basically a method by google to display some text on the screen...
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
These two lines suggest that your app has both vertcal and horizontal layout
android:text="@string/hello_world"
this is the text being displayed on your graphical layout
now go to layout > values > strings.xml
double click it
you will see something like this
now basically strings are resource files used to show text on display...
the string name cant have any spaces if it has then u will see errors
but the value of the string can have spaces
Activity
change the text in value field and see the result in graphical layout of the xml
now you basically need to use strings for each and every text that has to be displayed.......
End of part 1
Part 2
Adding of buttons and modifying them
now guys lets add some buttons to our project
navigate to src
in that you will find a java file open it (.java)
you will find something like this
HTML:
package com.exmple.addandsubract;
import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Layout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_layout, menu);
return true;
}
}
now you might be wondering what is this crap code ...
now lets add buttons
navigate into layout open up the xml
your screen will show up this
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
now within the closing of relative layout
copy paste this
HTML:
<Button
android:id="@+id/bsub"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="79dp"
android:text="@string/sub" /
every button must have an id for our convenience we have added a bsub as our program is to add and subtract a number
HTML:
android:layout_width="match_parent"
the layout width specifies the size of the width of the button
as i have said before match_parent is to occupy the whole screen..if you want it smaller you can set it in dp(density pixels)
HTML:
android:text="@string/sub"
you cant hard code stuff into the button u need to refernce it to a string i have referred it to the string sub
for this to work it requires you to add a string by the name sub in strings.xml
now do the same code again for button add
after this you will have something like this showing up
now that we have our button's set up we need to make this work (in real add java to it)
to accomplish this we need to link xml's to java
this may sound like greek and latin but guys stick with it u will understand everything
now below
HTML:
public class Layout extends Activity {
type this
HTML:
int counter=0;
Button add,sub;
TextView display;
as u may all know we should define a variable before we use them
as we are working with number (basically integars we use integar to define them
now we basically define display as textview
now coming to the real java part
HTML:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);
after this chunk of code
type
HTML:
counter=0;
the counter is the number which should be displayed on the screen for us
i have decided to start with 0 you can set it to any number that you prefer
now type this
HTML:
add = (Button) findViewById(R.id.badd);
sub = (Button) findViewById(R.id.bsub);
what this basically says is that add is a button and its id(in the xml) is badd.. findviewbyid is the method for referencing
now its the same for sub button too
HTML:
display = (TextView) findViewById(R.id.textView1);
this will set our display to textview1 which is our activity.xml this may sound as bloat to you but its handy when working with many xmls
now type
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
display.setText("Your total is " + counter );
}
});
i will explain what this does
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
display.setText("Your total is " + counter );
}
});
type add. then all lists will popup select onclicklistener(this makes the button clickable)
within the brackets of onclicklistener type new(as its a new button) leave a space type view.onlclicklistener(again you will see popups
now what is between this two brackets is what happens when the button is clicked now add this in between these brackets
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter=counter+1;
display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter=counter-1;
display.setText("Your total is " + counter );
}
});
HTML:
counter=counter-1;
this decrements the counter value by 1
after the counter is decremented we need to change the display to show the value of it
we do that by typing this
HTML:
counter=counter-1;
display.setText("Your total is " + counter );
now do this for both buttons test the app on emulator
Have doubts comment below
liked the thread rate it that gives me moral confidence and motivation
1st reserved op has plans of increasing
reservation
2nd
one final one for the day... :cyclops:
thanks! :good:
its to the point and very precise!
View attachment HelloWorld.apk
how do i add an icon? mine is the default andy.
And is it possible to open an app (eg launcher pro) in eclipse and mod it as per my wish?
Harryhades said:
thanks! :good:
its to the point and very precise!
View attachment 1401833
how do i add an icon? mine is the default andy.
And is it possible to open an app (eg launcher pro) in eclipse and mod it as per my wish?
Click to expand...
Click to collapse
There are two ways to add icon after giving the package name in the next menu you can change the icon....or go re drawabl-hdpi and replace the icon.png by the one that u want it should be case sensitive and it should be the same text....
For the 2nd question
yes you can mod these apps i have tried adw from cm'r repo but it should work with launhcer pro to btw the app has to deodexed.....
Thanks
Thanks bro i have started developing one :good:
completing the guide this sunday
I realize this is a few years old but I'm new to developing apps and I been trying to get this to work so that I can add a number to a number stored in a database. The number is put in the database via "edittext". When I try this my number gets replaced with "false" when I hit the add button.
Sent from my LG-LS995 using XDA Free mobile app

[DEV] [SMALI] A Few Custom Views

Hey XDA,
I've been making a number of custom Views for my own use, and figured I'd share a few of them, in case anyone else finds them useful. These are all ready-made smali files, that can be dropped into any app you'd like to use them in, no IDs or anything needed. You're welcome to use them for personal use, but if you use any of them in any other release, please send me a PM with a link to the release, and be sure to give appropriate credit.
Anyway, what's included:
CPUFrequency
Extends TextView.
Shows current CPU frequency and unit (MHz or GHz, depending on the current value).
Updates once per second.
CPUTemperature
Extends TextView.
Shows current CPU temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
BatteryVoltage
Extends TextView.
Shows current battery voltage in mV.
Updates once per second.
BatteryTemperature
Extends TextView.
Shows current battery temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
CurrentNetwork
Extends TextView.
Shows SSID of currently connected WiFi network.
If WiFi is off or disconnected, shows carrier name.
If no WiFi or mobile network is connected, shows "Network Unavailable".
Updates whenever connection status changes.
This View requires two permissions: android.permission.ACCESS_WIFI_STATE and android.permission.ACCESS_NETWORK_STATE (These permissions already exist in framework-res andSystemUI).
SelfAnimatingImageView
Extends ImageView.
Automatically begins any XML frame animation or vector animation (set with android:src) when they come into focus, without any additional code required.
These Views only animate/update themselves while the screen is on and they are visible/in focus, so there shouldn't be any memory leaks or anything. The above descriptions pretty much explain them, but if you want to see them, you can download a sample app here:
sample.apk
md5: 9225d2ad828830de2bfd45f936fb3352
Click to expand...
Click to collapse
***Note: The sample apk asks for two permissions. These are for the CurrentNetwork View, as explained above. Also, it is for Lollipop only, due to the inclusion of an animated-vector example.
Usage
To use, simply copy the smali files into your decompiled apk (preserving the folder structure), and use them in any layout, like this:
Code:
<com.android.morningstar.NameOfCustomView android:layout_width="wrap_content" android:layout_height="wrap_content" etc... />
All standard TextView and ImageView attributes still work, though for the extended TextViews, android:text isn't needed.
Here's part of a layout where I'm using all the TextViews ('thumper' is the WiFi SSID):
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Download
All of the Views are in a single zip file, and any that you don't use can be deleted.
Custom Views.zip
md5: 80c2cd01fd65a7733e538303a5ecab60
Click to expand...
Click to collapse
Morningstar said:
Hey XDA,
I've been making a number of custom Views for my own use, and figured I'd share a few of them, in case anyone else finds them useful. These are all ready-made smali files, that can be dropped into any app you'd like to use them in, no IDs or anything needed. You're welcome to use them for personal use, but if you use any of them in any other release, please send me a PM with a link to the release, and be sure to give appropriate credit.
Anyway, what's included:
CPUFrequency
Extends TextView.
Shows current CPU frequency and unit (MHz or GHz, depending on the current value).
Updates once per second.
CPUTemperature
Extends TextView.
Shows current CPU temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
BatteryVoltage
Extends TextView.
Shows current battery voltage in mV.
Updates once per second.
BatteryTemperature
Extends TextView.
Shows current battery temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
CurrentNetwork
Extends TextView.
Shows SSID of currently connected WiFi network.
If WiFi is off or disconnected, shows carrier name.
If no WiFi or mobile network is connected, shows "Network Unavailable".
Updates whenever connection status changes.
This View requires two permissions: android.permission.ACCESS_WIFI_STATE and android.permission.ACCESS_NETWORK_STATE (These permissions already exist in framework-res andSystemUI).
SelfAnimatingImageView
Extends ImageView.
Automatically begins any XML frame animation or vector animation (set with android:src) when they come into focus, without any additional code required.
These Views only animate/update themselves while the screen is on and they are visible/in focus, so there shouldn't be any memory leaks or anything. The above descriptions pretty much explain them, but if you want to see them, you can download a sample app here:
***Note: The sample apk asks for two permissions. These are for the CurrentNetwork View, as explained above. Also, it is for Lollipop only, due to the inclusion of an animated-vector example.
Usage
To use, simply copy the smali files into your decompiled apk (preserving the folder structure), and use them in any layout, like this:
All standard TextView and ImageView attributes still work, though for the extended TextViews, android:text isn't needed.
Download
All of the Views are in a single zip file, and any that you don't use can be deleted.
Click to expand...
Click to collapse
Any chance you could make them into xposed modules?
Tired Storeman said:
Any chance you could make them into xposed modules?
Click to expand...
Click to collapse
@Morningstar
I can't stop laughing at the picture above.
I don't see a usage example
evilvoice said:
@Morningstar
Can you make these for Windows 3.11?
[emoji6]
Click to expand...
Click to collapse
Sure! Let me dig out my old 486/DX and I'll get right on that.
[emoji57]
Great job man
Nice mate!
evilvoice said:
@Morningstar
I can't stop laughing at the picture above.
I don't see a usage example
Click to expand...
Click to collapse
Fixed. Stupid Tapatalk removes anything inside code tags every time you edit a post...Stupid Tapatalk...
Morningstar said:
Fixed. Stupid Tapatalk removes anything inside code tags every time you edit a post...Stupid Tapatalk...
Click to expand...
Click to collapse
LOL yea. I have issues with it from time to time...makes me so mad.
Anyways, I am trying to add Current Network. I created the folder structure (the attachment on xda has no folders, but figure it out with the first line in one of the smali files. I wanted to add this to the device information I already have, so I tried to show Current Network above Device Info with this in status_bar_expanded
Code:
<RelativeLayout android:gravity="center" android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.android.morningstar.CurrentNetwork android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/network" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<com.potato.statusbar.deviceInfo.Information android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/device_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/network"/>
</LinearLayout>
</RelativeLayout>
But that causes a fc in SystemUI
This is what it was originally
Code:
<LinearLayout android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/device_info" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.potato.statusbar.deviceInfo.Information android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Can you tell me what I did wrong/how to fix? Thanks!!!
Morningstar said:
Hey XDA,
I've been making a number of custom Views for my own use, and figured I'd share a few of them, in case anyone else finds them useful. These are all ready-made smali files, that can be dropped into any app you'd like to use them in, no IDs or anything needed. You're welcome to use them for personal use, but if you use any of them in any other release, please send me a PM with a link to the release, and be sure to give appropriate credit.
Anyway, what's included:
CPUFrequency
Extends TextView.
Shows current CPU frequency and unit (MHz or GHz, depending on the current value).
Updates once per second.
CPUTemperature
Extends TextView.
Shows current CPU temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
BatteryVoltage
Extends TextView.
Shows current battery voltage in mV.
Updates once per second.
BatteryTemperature
Extends TextView.
Shows current battery temperature and unit.
Click to toggle between Fahrenheit and Celsius.
Updates once per second.
CurrentNetwork
Extends TextView.
Shows SSID of currently connected WiFi network.
If WiFi is off or disconnected, shows carrier name.
If no WiFi or mobile network is connected, shows "Network Unavailable".
Updates whenever connection status changes.
This View requires two permissions: android.permission.ACCESS_WIFI_STATE and android.permission.ACCESS_NETWORK_STATE (These permissions already exist in framework-res andSystemUI).
SelfAnimatingImageView
Extends ImageView.
Automatically begins any XML frame animation or vector animation (set with android:src) when they come into focus, without any additional code required.
These Views only animate/update themselves while the screen is on and they are visible/in focus, so there shouldn't be any memory leaks or anything. The above descriptions pretty much explain them, but if you want to see them, you can download a sample app here:
***Note: The sample apk asks for two permissions. These are for the CurrentNetwork View, as explained above. Also, it is for Lollipop only, due to the inclusion of an animated-vector example.
Usage
To use, simply copy the smali files into your decompiled apk (preserving the folder structure), and use them in any layout, like this:
Code:
<com.android.morningstar.NameOfCustomView android:layout_width="wrap_content" android:layout_height="wrap_content" etc... />
All standard TextView and ImageView attributes still work, though for the extended TextViews, android:text isn't needed.
Here's part of a layout where I'm using all the TextViews ('thumper' is the WiFi SSID):
Download
All of the Views are in a single zip file, and any that you don't use can be deleted.
Click to expand...
Click to collapse
Nice work bro. [emoji12]
Cowboy from Hell on a twisted trail.
Koffed From my Big Ass Outlaw Phone.
Awesome work!
evilvoice said:
LOL yea. I have issues with it from time to time...makes me so mad.
Anyways, I am trying to add Current Network. I created the folder structure (the attachment on xda has no folders, but figure it out with the first line in one of the smali files. I wanted to add this to the device information I already have, so I tried to show Current Network above Device Info with this in status_bar_expanded
Code:
<RelativeLayout android:gravity="center" android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.android.morningstar.CurrentNetwork android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/network" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<com.potato.statusbar.deviceInfo.Information android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/device_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/network"/>
</LinearLayout>
</RelativeLayout>
But that causes a fc in SystemUI
This is what it was originally
Code:
<LinearLayout android:gravity="center" android:layout_gravity="bottom|center" android:id="@id/device_info" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.potato.statusbar.deviceInfo.Information android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Can you tell me what I did wrong/how to fix? Thanks!!!
Click to expand...
Click to collapse
Oops. I'll reupload when I get home and include the folders, so it's jot confusing for others. Thanks for pointing that out.
Your XML looks fine to me, can you pull a logcat of the FC? Also, check your SystemUI's manifest and make sure it has the two permissions mentioned in the OP. Both of the ones I tested it on already had those, but maybe not all do?
Nice job bro! But can you tell me how to do this?
I can't seem to load these modules? I can haz custom views?
Looks cool! Can we see some screenshots so we know just what we're getting into?
So, I went back and looked at my log and it had nothing to do with these, so I decompile the last working version and made the edits again. It works, but one issue. How can I get it above the device information like I wanted?
Edit: so I've decided to try and get these custom views to exist beside device info. For some reason, all the custom views print on the exact same line instead of on top of each other. I'll post code in a minute, but any ideas how to get it all on separate lines?
Code:
<RelativeLayout android:gravity="center" android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.android.morningstar.CPUFrequency android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/cpufreq" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.morningstar.CPUTemperature android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/cputemp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/cpufreq" />
<com.android.morningstar.BatteryVoltage android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/battvolt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/cputemp" />
<com.android.morningstar.BatteryTemperature android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/batttemp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/battvolt" />
<com.android.morningstar.CurrentNetwork android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/network" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/batttemp" />
<com.potato.statusbar.deviceInfo.Information android:textSize="10.0sp" android:textColor="#ffffffff" android:gravity="center" android:id="@id/device_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/network" />
</LinearLayout>
</RelativeLayout>
@Morningstar you also need to add "Name of Custom View" to ids.xml. I had an error when not adding them to that xml file.
For someone who already did this mod to system ui can I get your apk
evilvoice said:
@Morningstar you also need to add "Name of Custom View" to ids.xml. I had an error when not adding them to that xml file.
Click to expand...
Click to collapse
It depends on how you're using it. The smali files don't reference any IDs, so they'd only be needed if you've added them to the View in your XML (for positioning in a RelativeLayout, for example). If you don't need to position the View relative to something else, no ids are necessary.
malbert16442 said:
For someone who already did this mod to system ui can I get your apk
Click to expand...
Click to collapse
What exactly do you need out of it?
Morningstar said:
It depends on how you're using it. The smali files don't reference any IDs, so they'd only be needed if you've added them to the View in your XML (for positioning in a RelativeLayout, for example). If you don't need to position the View relative to something else, no ids are necessary.
What exactly do you need out of it?
Click to expand...
Click to collapse
I just want to see the layout of system ui of someone who applied the views their
Sent from my SM-G900T using Tapatalk
?
Sent from my SM-G900T using Tapatalk

Question A newbie Android Application

I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
pax0 said:
I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
View attachment 5523271
Click to expand...
Click to collapse
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {n
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.
wpscully said:
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidnClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.
Click to expand...
Click to collapse
That's a good start, but I think you did some iOS button handling
For a button, you need to get a reference to it in your Java and assign a click listener. It won't automatically find it like Xcode by using the same name.
Code:
...
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button1);
button.setOnClickListener(view -> {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
});
...
In older Android Studio, you had to do
Code:
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
but now you can use a lambda (->) to replace the "common" stuff
the suggested solutions gives plenty of errors see below.
Hi. Speaking of Android development anybody know where can I find the C++ and Java Android development section of this forum? Thanks!
It gives plenty of errors
The sample Java program I posted in post #2 was meant to "largely replace" all the lines in MainActivity.java. It looks like you cut/pasted some of the suggested code into the middle of the existing skeleton Java code which Android Studio creates on your behalf. That approach won't work... a bit more effort is involved.
For example, there should be one and only one record in the Java file starting with the work "package". In your screen shot I see two. The second occurrence is incorrect and probably causing most of the errors. I would keep the first occurrence of package, because that's the naming that your Android Studio gave to the program. Delete the second "package com.example.my" which I think you pasted from me into the original file.
Also, there are several "import" records needed. In my post I included the only four I thought would be needed. However in your screen shot, on the second line, I see an import record with "three dots" (an ellipsis). This is Android Studio's way of hiding code from your view, which can be confusing to new users. You should mouse-click on those three dots to expose the hidden code. Then make sure there are no duplicate import records, when comparing what was originally in the file with what you cut/pasted.
I sent a private message to you with a link to my example code. It might work for you if you copied the folder into the same location you save your Android Studio projects. Of course, I can't be sure it will work. That's why I thought it best to include just a few lines of code in my original post.
Naming of things in Android Studio matters. I called my button "button" and my onClick "button1" and it must match eXaCtLy in the XML file and the Java code. (Case matters.) I can't see all your code so you'll need to ensure the naming matches exactly. (It's intuitively better if you name your button more appropriately... like "submit" if that's what the button is supposed to do.) Also, the number of braces { } will matter, as they indicate the structure of the program in Java.
In closing, it's very hard to explain all the nuances of this development environment through posting on XDA. Which is why it may be worth your time to run through the tutorial from Google. The tutorial creates a very simple application, but it also shows a lot of what I think you want to do, which is layout an end-user interface and have a button which when pressed will go off and do some additional work.
PS: I saw some errors in post 2, which I've cleaned up. A colon and the oh was interpreted as an emoticon. Ugh.
There's a learning curve involved here... learning Android Studios. If you can figure it out you might be able to earn a good living! I confess it's too hard for me. ;-)
pax0 said:
the suggested solutions gives plenty of errors see below.
View attachment 5523855
Click to expand...
Click to collapse
Your best bet is to start small. Download an example project from an online tutorial. The ones from Google are typically garbage. Plenty of sites include a sample with their getting started.
Make a small change and see what happens when you run it. Try a bigger change next. Try adding something. Try starting a new project. Try adding your stuff to that. Next thing you know, you're explaining it to the next person.
Admittedly, this isn't a section really made for learning the basics of app development. It's more focused on one device. General will be more help.

Categories

Resources