Modify apnsettings.java to re-enable APN menu? - Galaxy S 4 Developer Discussion [Developers-Only]

Last night I successfully compiled LineageOS 14.1 for my SPH-L720 / jfltespr S4. It works pretty darn well. I'm not really a developer but I know how to follow directions.
Trouble is that I use Freedompop, Sprint MVNO with a weird APN, and my usual method of flashing the Freedompop APNs (XDA post) doesn't work.
With the APN settings disabled, I don't have other convenient methods of tinkering with that, so my question is: Why not recompile my ROM to remove the restrictions on the APN menu?
Found the package here: apnsettings.java on Git
And I suspect the code to modify might be here:
Code:
@Override
public EnforcedAdmin getRestrictionEnforcedAdmin() {
final UserHandle user = UserHandle.of(mUserManager.getUserHandle());
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, user)
&& !mUserManager.hasBaseUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
user)) {
return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
}
return null;
}
So I'm really barely dipping my toe into development. Could someone offer a tip as to how to safely remove this restriction?
EDIT: OK! I think I have a clue.
All of the restrictions in this package are governed by the private boolean mUnavailable, which gets its value from isUiRestricted() . This boolean interacts with a lot of if-then statements in the package. If I wanted to be reckless and break things, I could probably just cut out all of the code that checks for that boolean.
Unless anyone objects, I'll try it and see what happens.
EDIT2: Hah, no, of course that didn't work. Terrible idea. Well I'll just poke around some more and edit here if I find something.

Related

[DEV] Acessing IR interface

I just started developing for my new Sony tablet and was curious if I can send IR codes with my own app instead of using the Sony app. Here is what I've achieved so far. Maybe someone finds this information usefull and maybe we can provide further information based on this.
The service kinda works, the callbacks get called, I can read raw commands using learnKey() method and I can get the keys for specific devices using getKeyList() but sending IR pattern or key codes to devices seems not to be working quire right, although the callback gets status OK after sending.
Sony created a DataProvider to share data between the app and the service. Thanks to this fact I queried following URI content://com.sony.nfx.app.irremote.provider/learnt and found all custom learnt codes I added via the Sony app. But even using this exact data doesn't seem to do anything when sending to the device.
Access to IR service is restricted by permission and process so our AndroidManifest.xml should look like this:
Code:
<uses-permission android:name="com.sony.nfx.app.irremoteservice.permission.EXECUTE_SERVICE"/>
<application ... android:process=":remote">
...
</application>
Required AIDL files:
Code:
package com.sony.nfx.app.irremoteservice;
import com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback;
interface IUEIControlService {
int sendKey(int i, int j, int k, byte byte0);
int sendSonyCode(int i, int j, byte byte0, int k, byte byte1);
int sendIRPattern(int i, int j, byte byte0, in byte[] pattern);
int sendStopIRSend(int i);
int getKeyList(int i, int j);
int learnKey(int i);
void registerCallback(IUEIControlServiceCallback callback);
void unregisterCallback(IUEIControlServiceCallback callback);
}
Code:
package com.sony.nfx.app.irremoteservice;
interface IUEIControlServiceCallback {
void onCommandComplete(int i, int j);
void onLearntKey(int i, in byte[] abyte0);
void onGetKeyList(int i, int j, in int[] ai);
}
Basic sample code:
Code:
package ir.remote.android;
import java.util.Arrays;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.sony.nfx.app.irremoteservice.IUEIControlService;
import com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback;
public class RemoteTest extends Activity implements ServiceConnection {
private static final String LOG_TAG = "RemoteTest";
private ServiceBinder serviceBinder = new ServiceBinder();
private IUEIControlService remoteService = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String serviceAction = IUEIControlService.class.getName();
Intent serviceIntent = new Intent(serviceAction);
bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
}
public void onServiceConnected(ComponentName name, IBinder service) {
try {
Log.d(LOG_TAG, "Service connected!");
remoteService = IUEIControlService.Stub.asInterface(service);
remoteService.registerCallback(serviceBinder);
} catch (Exception e) {
Log.e(LOG_TAG, "Error connecting to service!", e);
}
}
public void onServiceDisconnected(ComponentName name) {
Log.d(LOG_TAG, "Service disconnected!");
remoteService = null;
}
public static class ServiceBinder extends IUEIControlServiceCallback.Stub {
public void onCommandComplete(int i, int j) throws RemoteException {
Log.d(LOG_TAG, "onCommandComplete(" + i + ", " + j + ")");
}
public void onGetKeyList(int i, int j, int[] ai) throws RemoteException {
Log.d(LOG_TAG, "onGetKeyList(" + i + ", " + j + ", " + Arrays.toString(ai) + ")");
}
public void onLearntKey(int key, byte[] value) throws RemoteException {
Log.d(LOG_TAG, "onLearntKey(" + key + ", " + Arrays.toString(value) + ")");
}
}
}
Good start
I'm really glad to see someone working on accessing the IR interface. The IR is the primary differentiator that made me decide to buy the Sony Tablet S. I haven't got it yet though, getting it on Monday evening.
I'm only a noob at development, but have started learning Android dev and the start you've made is bound to help. So thanks a lot.
I look forward to seeing your progress.
Luke
Hello Peacemaker2000,
I'm quite new to programing on android (and in java for that matter) so, sorry for the noob questions here.
I have just received my sony tablet last week-end and I think building a custom remote to my needs would be a great hands on exercice
Also I'm a bit disapointed by the natif app which doe not support macro nor look customizaton.
I have tried to start working with all your samples and code to see what I can get to work, but my first concern is about the AIDL files, how do you import the "com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback" ?
The only file that i have found on my tablet, in a "framewok" folder somewhere is "com.sony.nfx.app.irremoteserviceif.jar", I have tried to referenced it by adding to the build path but it is as far as I have been for now.
Any more help / explanation would be greatly appreciated !
Thanks,
Tom.
Good Job Peacemaker,
Main reason i bought it is universal remote control (of course i m an android fan also). If you think that you have to pay 2000$ for a philips pronto remote, SONY did a good start. I am waiting for a customized remote software so to be able to add new buttons, keys etc.
Thank you,
Chris
+1 for me. the ability to have a custom layed out remote with macros and such, I would buy that app.
I ASSUME you have signed up for the sony developers kit they just released, I dl'd it but don't have the time to get into development currently.
Alan
I did subscripbe and download the sdk but only found samples / references for the largescreen / dualscreen layout of the 2 sony tablets, nothing related to the IR.
I did look in to doing something with the IR blaster but couldn't find anything about how to access it. I might start digging around to build the app I was thinking of in my time off over Christmas
Hello to everybody and i wish you a Happy New Year!!!!!!!!!
Any news about IR?
I wonder who will make a new software remote control more customizable, with macros, buttons etc.
Chris
Athens GREECE
I agree with everyone so far about wanting a better app than the remote control one supplied by Sony. I tried learning a macro from my PDA with its universal remote control app, but it refused to learn it. It was OK with single key presses, indeed it is very sensitive.
I bought the Tablet S for my wife, simply because of the eBook reader capability amongst other things but also as a trial for a new replacement universal remote control. This is the first device for ages to have an IR facility built in. I use an old HP Jornada but the screen is mis-behaving after around 10 years of hard labour as a Universal Remote Control. I have found the ability to program my own designed GUI for my numerous cinema, TV etc. devices has been excellent. The Tablet S app is OK in that it has enough keys to cover most remotes. The facility to be able to re-label the keys and choose which of the icons can be which keys is good. It is slightly limited as most of the icons on the left hand panel are fixed labels. Therefore it could be improved.
I would support anyone writing such an app. I would even pay for it! Now that's novel..... Good luck developers.
Thank you so much Peacemaker2000 for sharing your code and ideas.
It works like a charm getting the keys from a remote control and using the data for your own app. I would really like to know what kind of parameters you have to send to get a full keylist of a TV.
Right now I'm just saving the key data from my remote control and don't have any clues how to generally get all possible keys my TV understands. Would be great if you or anybody else who knows this, could share it with us.
If anybody would like to have a functional piece of code from my current prototype, just let me know, right now I have no problems of controlling my Sony Bravia KDL-32W4000.
Perhaps a Mystery Gift app could be developed for use with pokemon gold on a gameboy colour, those were the days
Seems to be quite easy to get a keylist from the actual service:
Code:
int REMOTE_TYPE_ID_KDL_32W4000 = 508;
remoteService.getKeyList(0, REMOTE_TYPE_ID_KDL_32W4000);
You'll get the list in IUEIControlServiceCallback.Stub.onGetKeyList() and execute the appropriate key with:
Code:
int REMOTE_TYPE_ID_KDL_32W4000 = 508;
int ON_OFF_KEY = 18;
remoteService.sendKey(0, REMOTE_TYPE_ID_KDL_32W4000, ON_OFF_KEY, (byte) 0);
remoteService.sendStopIRSend(0);
There you go, TV goes on and off.
I will donate to anyone developing better IR control app.
It will put all that smart LCD screen remotes that they are selling for $1000 and more out of existence.
There is an example of really good IR remote control application. Extremely feature rich. It is called RemoteControl II from http://wincesoft.de/html/remotecontrol_ii.html.
It is only available for Windows CE/Mobile devices.
open source project
hi all, it could be nice to start an open source project, so everyone can collaborate. like me.
david8 said:
hi all, it could be nice to start an open source project, so everyone can collaborate. like me.
Click to expand...
Click to collapse
I've just whipped up a quick Git repo now. Here's the link: https://github.com/agc93/Tablet-S-IR-Control
It'll only be empty atm, because I'm a bit busy at work, but if anyone wants to give it a try, feel free!
agc93 said:
I've just whipped up a quick Git repo now. Here's the link: https://github.com/agc93/Tablet-S-IR-Control
It'll only be empty atm, because I'm a bit busy at work, but if anyone wants to give it a try, feel free!
Click to expand...
Click to collapse
Great! It's a good beginning.
Hi,
I'm an Android beginner developer.
I recently bought a Sony Tablet S and trying to create my own IR Remote App...why?
Sony default IR Remote App don't provides macros.
Here are the main features i'm thiking about:
A dialog box popup automatically when tablet is removed from his dock and shaked...this is managed by a local service)
This dialog provides two options : 1) Default usage of the tablet or 2) Launch my own IR Remote App
This custom App provides only 2 macros : 1) Listen to music or 2) Watch TV
Main challenges i'm facing (as you can easily imagine) is the IR interface implementation.
There's not much code sample on the web, probably because Sony Tablet S is the only device on the market embedding IR interface.
Here are my questions :
Do some one has successfully experienced this technology ?
Is it necessary to root the device before coding with IR interface ?
Do Sony provides specific library to access to IR interface ?
I suppose that each device that i want to remote control (Denon amplifier AVR-2311 and DVico Tvix 6600n for music listening) has an Infrared Hex Code. How do i use it in my classes ?
Waiting for your help
Regards
I for one am very interested in any application that comes close to a Philips Pronto in respect of functionality. The ability to design your own buttons and layouts as wll as have macros is all that is missing from the sony software and I'm sure its possible.
My Pronto is over 10 years old now and one of the reasons for purchasing the Tablet s was as a replacement.
Have a look at the pronto forums on remotecentral.com theres a vast array of downloads of layouts for Pronto edit and hence the hex codes which can be extracted. Many include discrete codes that can't be learned from remotes and are invaluable for macros.
You can also obtain the original editing software and load onto a virtual pronto. If you can produce an ap anything like that then I think you're onto a winner.
Apologies I'm unable to assist on a coding front as I'm a bit of a technonumpty.
Another very confused developer here trying to work out how Sony's bizarre remote calls function. To be honest, not having much luck, and Sony won't help.
If anyone knows how to get it going, please share, because that's all thats stopping me at the moment.
I already posted a working example for sending an IR signal with the tablet. ;-)
I'm also working on an own app with makro-capabilities, custom button layouting (own text, pictures, size, placement) and even custom gestures. I think I can give out a demo in about two weeks, so be a little bit more patient. ;-)
Of course the app will only work with the Tablet S.

how to start programming android?

Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
smartuse said:
Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
Click to expand...
Click to collapse
You may want to start with learning java; See here: http://mobile.tutsplus.com/tutorials/android/java-tutorial/. You may also want to learn C/C++. Take a browse around here: http://developer.android.com/guide/basics/what-is-android.html.
smartuse said:
Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
Click to expand...
Click to collapse
You'll also need the android sdk and I believe eclipse is a good bit of software.
Sent from my HTC EVO 3D X515m using XDA App
Android Application Development -o'Reilly
Don't understand!
I looked at linkes you have advised, but really don't understand some things: why used paranthesys ant other signs. I mean I understand that there is a syntax but I don't understand for example why used this type of paranthesis "()" but not this type "{}".
For example, I dont clearly understand this code
public class Cat {
private String mCatName;
Cat(String name) {
mCatName=name;
}
public String getName() {
return mCatName;
};
public void setName(String strName) {
mCatName = strName;
};
}
I can't find the explanation. I need a course from the begining. What do you recommend for me, friends?
Thank you guys!
This is the Syntax: get used to it, you can't change it anyway...
PHP:
//Make a class called Cat
public class Cat {
//set up a variable, type:String, Name:mCatName
private String mCatName;
//Constructor (method which runs by default)
Cat(String name) {
mCatName=name;
}
//Public: it can be called from everwhere (even other classes or programs)
//Method name: getName.
//It simply returns the content of the variable mCatname;
public String getName() {
return mCatName;
};
//Public: it can be called from everwhere (even other classes or programs)
//Method name: setName
//It sets the variable mCatName to the value of the input variable strName
public void setName(String strName) {
mCatName = strName;
};
}
This code is a class called Cat.
It got a String which represents the Cat's name. It is set to "name" by default.
With the methods getName and setName you can either output or change the name of the Cat.
This is very basic Java. You won't learn Java in a day, just learn bit for bit.
Thanks
But tell me please, how did you started programming? What was or from which source you started first. What were your first steps?
May be it will help me, because I don't know anything in programming.
Thank you
I started with html (not a real programing language, but helpful though)
Then we did some basics in school (Pascal, basic, .net, java) and i learned PHP and more Java in my free time.
Once you learn one programing language its rather easy to switch.
Java is a good base to start with.
There are tons of tutorials on the Internet which are great for beginners. I cant recommend you a specific, i only know German ones.
I'm going to post the book that I was taught from. I can't vouch for other books, they may be better - however the person who wrote this book was a lecturer at my university and he handed out photocopies of this book as we went through the module, while the book was still being written.
It was ammended based on feedback from a number of years of students and the parts of the language and concepts they found difficult. When I went into Uni I had no programming background beyond dabbling very lightly into HTML/PHP.
The book has exercises in it, as will any other book or online guide you find, I highly recommend attempting all of them as you progress.
http://www.amazon.co.uk/Java-Just-Time-John-Latham/dp/1848900252/ref=tmm_pap_title_0
Yes, I know it costs actual money, but for a going from complete beginner -> understand Java and its concepts well enough to begin thinking about putting it on your CV, I don't think that's such a bad thing - and he's deliberately put it at a cheap price point aimed at students, it should be 3-4x that amount to bring it in line with other university textbooks that are much less helpful.
smartuse said:
But tell me please, how did you started programming? What was or from which source you started first. What were your first steps?
May be it will help me, because I don't know anything in programming.
Thank you
Click to expand...
Click to collapse
I used a book called Object First with Java, BlueJ...
BlueJ is the IDE (where you type the code in to make programs) and its free.
Java is the language, we could talk you through the code above, but its better you learn it yourself, and then you will be able to read the code above.
Look into what Object Oriented Languages are, but tbh, that Book can be found online, its not cheap but I found it rather good!
http://www.amazon.co.uk/Objects-Fir...5628/ref=sr_1_1?ie=UTF8&qid=1325806069&sr=8-1
An amazon link to the book, hope this helps!
Thanks
Thank you, guys!
I'll try to find more information about Java online. Thank you all very much!
Also, look on you tube for "the new Boston" he makes some good programming videos
Which is difference between SDK and Oracle ?
I want to know which is difference between SDK and Oracle ?
Please help me I am new here and want to start programming.

ContentProvider actual data access

Hello all,
hope my question is not too strange - I need to know it for some security "research" i currently do
What I am looking for is the place in the source where the actual retrieving of information by the Contracts content provider is done. I know that this is deprecated but I think that it is a good start
I tried to trace the place in the source manually but I got stuck at this method:
Code:
public ContentProviderHolder getContentProvider(IApplicationThread caller,
String name) throws RemoteException
in the file
/android/frameworks/base/core/java/android/app/ActivityManagerNative.java
I started from the following code snippet:
Code:
Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
String test = People.CONTENT_URI.getPath();
txt.append(test);
I think that the ContentProvider is implemented in
/android/frameworks/base/core/java/android/provider/Contacts.java even though this class does not extends ContentProvider (I thought that each ContantProvider must extend this class).
Can someone maybe help me and tell me where to look ?
Oh jea and i have a second question. What I want to do is to redirect every Call to the contacts contentprovider to a fake content. So I thought i could implement my own contentprovider e.g. fakeContacts and redirect each call to my fake content provider (by altering the source). Is this a good idea or is their a "better" idea to perform this "lying" to the contact app ???
Thank you so much

Hosts file for Ad Blocking

Hi guys, I am presenting you the latest hosts file to block ad in apps. It works for me for all apps I installed on my player (Angry birds etc.).
How to use:
1. Download attached file and unzip it;
2. Copy the hosts file to your player;
3. Open system/etc with RE and replace the original hosts file and set permission "rw-r-r" (remeber mount R/W before and R/O afterwards);
4. Reboot and you'll enjoy ad free apps from now on.
Why not just use the adfree project? Or join it?
Sent from my Triumph using Tapatalk
Guess that's how ad free works. It patches hosts files.
Sent from my YP-G70 using xda premium
njguyc said:
Hi guys, I am presenting you the latest hosts file to block ad in apps. It works for me for all apps I installed on my player (Angry birds etc.).
How to use:
1. Download attached file and unzip it;
2. Copy the hosts file to your player;
3. Open system/etc with RE and replace the original hosts file and set permission "rw-r-r" (remeber mount R/W before and R/O afterwards);
4. Reboot and you'll enjoy ad free apps from now on.
Click to expand...
Click to collapse
Ad a developer i am disgusted with people blocking ads in their applications. I understand why you guys are doing this and yeh they can be really annoying! Blocking ads on a webpage is much more understanding than blocking from the application. Nowadays our screens are bigger than 4 inches, can you really not give up a little bit to help out the person that spends hours a week keeping up with a free application to make you happy. I spend hours a week writing my apps and I make NO PROFIT all the money I make from ads pays for my server costs.
I don't think people consider these things when they block ads. I'll admit I had ads blocked for a while but it's because the ROM I installed came with it.
Your not bad people for wanting to do this but please consider how morally incorrect it is to block these ads.If there is another developer reading this and also hates how people do this go ahead and add this to your MainActivity. It checks their hosts file for admob (or you can make it which ever ad you use) and if admob exists it pulls some tricker on the user. I've seen developers ask for SU in the app and then once they get it wipe all the admob lines from hosts file. Sorry guys but this needs to be done, your stealing from the developers.
BufferedReader in = null;
Boolean result = true;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/etc/hosts")));
String line;
while ((line = in.readLine()) != null)
{
if (line.contains("admob"))
{
result = false;
break;
}
}
} catch(Exception e){}
if(result == false){
Toast.makeText(getApplicationContext(),"admob detected in /etc/hosts", Toast.LENGTH_LONG).show();
adBlockerFound();
}
public void adblockerFound(){
/**
Do all the bad stuff here. I usually use a dialog and simply notify the user but I still let them use the application. I pretty much give them a guilt trip. But if you wanna be nasty you can do this.finish();
**/
}
TheWall279 said:
Ad a developer i am disgusted with people blocking ads in their applications. I understand why you guys are doing this and yeh they can be really annoying! Blocking ads on a webpage is much more understanding than blocking from the application. Nowadays our screens are bigger than 4 inches, can you really not give up a little bit to help out the person that spends hours a week keeping up with a free application to make you happy. I spend hours a week writing my apps and I make NO PROFIT all the money I make from ads pays for my server costs.
I don't think people consider these things when they block ads. I'll admit I had ads blocked for a while but it's because the ROM I installed came with it.
Your not bad people for wanting to do this but please consider how morally incorrect it is to block these ads.If there is another developer reading this and also hates how people do this go ahead and add this to your MainActivity. It checks their hosts file for admob (or you can make it which ever ad you use) and if admob exists it pulls some tricker on the user. I've seen developers ask for SU in the app and then once they get it wipe all the admob lines from hosts file. Sorry guys but this needs to be done, your stealing from the developers.
BufferedReader in = null;
Boolean result = true;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/etc/hosts")));
String line;
while ((line = in.readLine()) != null)
{
if (line.contains("admob"))
{
result = false;
break;
}
}
} catch(Exception e){}
if(result == false){
Toast.makeText(getApplicationContext(),"admob detected in /etc/hosts", Toast.LENGTH_LONG).show();
adBlockerFound();
}
public void adblockerFound(){
/**
Do all the bad stuff here. I usually use a dialog and simply notify the user but I still let them use the application. I pretty much give them a guilt trip. But if you wanna be nasty you can do this.finish();
**/
}
Click to expand...
Click to collapse
I understand and agree with you on the fact that these ads 'compensate' the effort. I test an app and buy the paid add-free version if I like the app and intend to keep using it.
Yet I use an ad-blocking hosts file, because I consider displaying ads eating up my data plan to be stealing from me and that I do have a right to refuse getting spamed on my phone (in the Web browser I mean).
But by no means can I accept nor agree with you when you say it is ok to request su rights and change the system (even if it's just modifying or removing the hosts file) without requesting permission and clearly stating what your app is about to do and the consequences this has, that is a troian-like behaviour and is totally inappropriate and plainly inacceptable !
Check for ad-blocking, if you find some, pop-up an alert saying you disagree and hereby refuse your app to run, that is all the right you have on my device when I agree to install your app.
So suggesting to " Do all the bad stuff here. I usually use a dialog and simply notify the user but I still let them use the application. I pretty much give them a guilt trip. But if you wanna be nasty you can do this. " is a no go, sorry !
JP.
Sent from my custom ARHD 11.0.0 / Yank555.lu JB kernel v1.3 (Linux 3.0.38) powered Samsung Galaxy S3 using xda premium
TheWall279 said:
Ad a developer i am disgusted with people blocking ads in their applications. I understand why you guys are doing this and yeh they can be really annoying! Blocking ads on a webpage is much more understanding than blocking from the application. Nowadays our screens are bigger than 4 inches, can you really not give up a little bit to help out the person that spends hours a week keeping up with a free application to make you happy. I spend hours a week writing my apps and I make NO PROFIT all the money I make from ads pays for my server costs.
I don't think people consider these things when they block ads. I'll admit I had ads blocked for a while but it's because the ROM I installed came with it.
Your not bad people for wanting to do this but please consider how morally incorrect it is to block these ads.If there is another developer reading this and also hates how people do this go ahead and add this to your MainActivity. It checks their hosts file for admob (or you can make it which ever ad you use) and if admob exists it pulls some tricker on the user. I've seen developers ask for SU in the app and then once they get it wipe all the admob lines from hosts file. Sorry guys but this needs to be done, your stealing from the developers.
BufferedReader in = null;
Boolean result = true;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/etc/hosts")));
String line;
while ((line = in.readLine()) != null)
{
if (line.contains("admob"))
{
result = false;
break;
}
}
} catch(Exception e){}
if(result == false){
Toast.makeText(getApplicationContext(),"admob detected in /etc/hosts", Toast.LENGTH_LONG).show();
adBlockerFound();
}
public void adblockerFound(){
/**
Do all the bad stuff here. I usually use a dialog and simply notify the user but I still let them use the application. I pretty much give them a guilt trip. But if you wanna be nasty you can do this.finish();
**/
}
Click to expand...
Click to collapse
I don't do it with every app, but in cases like angry birds then its absolutely necessary because the ads prevent you from doing stuff in game. With ads that don't get in the way of using the app it's fine but when you put ads in really inconvenient places that's when I go to patching that.
There's an easier way to block ads...... but ads help support the devs.
Sent from my SPH-D710
Thanks!!
Thank YOU!!!
TheWall279 said:
Ad a developer i am disgusted with people blocking ads in their applications. I understand why you guys are doing this and yeh they can be really annoying! Blocking ads on a webpage is much more understanding than blocking from the application. Nowadays our screens are bigger than 4 inches, can you really not give up a little bit to help out the person that spends hours a week keeping up with a free application to make you happy. I spend hours a week writing my apps and I make NO PROFIT all the money I make from ads pays for my server costs.
I don't think people consider these things when they block ads. I'll admit I had ads blocked for a while but it's because the ROM I installed came with it.
Your not bad people for wanting to do this but please consider how morally incorrect it is to block these ads.If there is another developer reading this and also hates how people do this go ahead and add this to your MainActivity. It checks their hosts file for admob (or you can make it which ever ad you use) and if admob exists it pulls some tricker on the user. I've seen developers ask for SU in the app and then once they get it wipe all the admob lines from hosts file. Sorry guys but this needs to be done, your stealing from the developers.
BufferedReader in = null;
Boolean result = true;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/etc/hosts")));
String line;
while ((line = in.readLine()) != null)
{
if (line.contains("admob"))
{
result = false;
break;
}
}
} catch(Exception e){}
if(result == false){
Toast.makeText(getApplicationContext(),"admob detected in /etc/hosts", Toast.LENGTH_LONG).show();
adBlockerFound();
}
public void adblockerFound(){
/**
Do all the bad stuff here. I usually use a dialog and simply notify the user but I still let them use the application. I pretty much give them a guilt trip. But if you wanna be nasty you can do this.finish();
**/
}
Click to expand...
Click to collapse
Doesn't work anymore on latest jelly bean retard. Screw your ads, oh yea, and permissions pro will straight smack down your weak ass app perm
P.s. there's other methods of ad blocking besides having a host file in system/ect. I just have crossbreader and have the target host file in a custom location. Boom, you're little hack can't find it. I will never have any ads and always be one step ahead with the latest and greatest
Or you can turn of data or WiFi
Sent from my YP-G70 using xda app-developers app
heet1 said:
Or you can turn of data or WiFi
Sent from my YP-G70 using xda app-developers app
Click to expand...
Click to collapse
You are right, but some apps have ads and need Wi-Fi. That is when you use adblock.
The Wall279, please list apps you develop so I can avoid them like the plague, please.
Sent from my YP-G70 using Tapatalk 2
heet1 said:
Or you can turn of data or WiFi
Sent from my YP-G70 using xda app-developers app
Click to expand...
Click to collapse
Cool you have the same device i do.How exactly do i "set permission "rw-r-r" (remeber mount R/W before and R/O afterwards);"?
I would really appreciate it.
heet1 said:
Or you can turn of data or WiFi
Sent from my YP-G70 using xda app-developers app
Click to expand...
Click to collapse
If I don't click on ads, the developer of the app that have ads get money or not?
If yes, I see that an ads is a webpage with no zoom on it (Times ago i saw an ads that were scrollable in my player and not scrollable in my n7000 ), can anyone make an ads invisible (or can run it in an under-game level (like photoshop)of an app?
Work on Debian ?
TheWall279 said:
if(result == false){
Click to expand...
Click to collapse
As a developer you should be ashamed of yourself.

[Q] Java/android not understanding oop

Hi guys,
Im really trying to learn java but think Im getting very confused. I have a class which holds names and information, In my android program I have the user enter a load of names which then are passed as an array to my next activity. Whenever I try to create objects from each name in the array it wont do it? Ialso understand that this may be a bad way of doing this as names will change so how would I reference them. Maybe using the array[pos] to create objects... so instead of name.printweight(); I could use 1.printweight();
I really hope above is readable or understandable as to what I am trying to learn
SUDO:
Take in names of competitors
Pass array of competitors to next activity
for loop to get each competitor name entered to a string
create an object using the competitors name (e.g name.birthday)
class competitor:
dob
weight
highest score
time
I think you cant use a string name or an int to create objects but how else would I create several competitors in my class?
Im reading some books I bought and I really am struggling to make sense of all this. Please be patient with me...
Kind regards
Phil
Think I got it.....
for (int i = 0; i < numcompetitors; i++)
{
String competitorName = (String) competitorsArray;
TextView txtOutput = (TextView) findViewById(R.id.edttxtOutput);
txtOutput.append(competitorName + " ");
//create an object of this competitor
competitorsArray = new Competitor();
((Competitor) competitorsArray).average();
}
I couldn't really understand what you are having a problem with. The code you posted might be working but it really doesn't seem like a good way of doing what you are trying to do.
I'd like to help you out but first can you please explain a bit more clearly? Maybe even post your code, so that its easier for me to understand.
So... if I understood you, you need something like this:
class competitor:
dob
weight
highest score
time
Names entered:
A,B,C
Result:
A.dob, A.weight, A.highestscore, A.time
B.dob, B.weight, B.highestscore, B.time
C.dob, C.weight, C.highestscore, C.time
Right? Well, it can't be achieved using Java, it doesn't allow you to assign programatically names to variables. However, you can use a little trick based on an array:
Code:
//Remember: you have a class named "competitor" containing several variables
String[] Names= {"Uno","Dos","Tres"}; //the array passed by the other activity
competitor[] playerData=new competitor[Names.length]; //an array, to store copies of the competitor class (a copy for each name entered)
for(byte i=0;i<Names.length;i++){
playerData[i]=new competitor(); //Initializing the copy...
playerData[i].dob= //Storing data for each name entered...
playerData[i].weight=
playerData[i].highestscore=
playerData[i].time=
}
And that's all... 1st player's data will be stored in the position 0 of the array, 2nd player's data in the position 1... and so on.
BTW, instead use 2 activities, is more easy to use only an activity, changing its layout when you need a GUI's change (yep, it's possible ).

Categories

Resources