HI! It was my first thread in Java Dev in this forum :fingers-crossed:
I Want to presend you my first Class for Android App Developers.
CPUClass
Now you Can Get CPU Information , CPU Speed and CPU Scaling in your APP
I write it half year ago so sorry for this code. important that works :laugh::laugh:
What you can without SU:
-Get Max CPU Frequency
-Get Min CPU Frequency
-Get CPU Information
-Get current CPU Frequency
-Get current governor
Get governor list
And with SU:
-Set Max CPU Frequency
-Set Min CPU Frequency
-Set governor
HOW TO USE IT
in app you must init it
Code:
CPUClass.init(false) // if you want only "get"
or
Code:
CPUClass.init(true) // if you want "get" and "set" CPU
Here is ScreenShot with use this class
{
"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:
https://github.com/CheQ/android_classes/blob/master/CPUClass
Testing on Alcatel Ot -908 (GB) and LG L5(4.1).
If clas doesn't work you can edit from which file Class must read CPU infro Here -
Code:
/* freq files */
public static String file_scaling_max = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" ;
public static String file_scaling_min = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" ;
public static String file_act_scaling_max = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq";
public static String file_act_scaling_min = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq";
public static String file_cur_freq = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq";
/* GOV files */
public static String file_act_gov = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor";
/* list files */
public static String file_scaling_list = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies" ;
public static String file_gov_list = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" ;
Enjoy!
bump
bump
Related
im trying to make an app and im stuck at the point where after Login button is pressed it mean to switch to TabActivity but i keep getting error "Aplication has stoped unxpectidly, Please try again"
Login.java
Code:
...
...
[SIZE=2]
[LEFT]Login.setOnClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] View.OnClickListener() {
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onClick(View view) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Check Login [/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]String username = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etUsername[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();
String password = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etPassword[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](username.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"g"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) && password.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"g"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])){
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// lblResult.setText("Login successful."); [/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]Intent myIntent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent(view.getContext(), Activity2.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
startActivityForResult(myIntent, 0);
} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]lblResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login failed. Username and/or password doesn't match."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
} [/LEFT]
});
...
...
[/SIZE]
AndroidTab.java
Code:
...
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]package[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] com.cs2001.gpt1;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.app.TabActivity;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.Intent;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.res.Resources;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.os.Bundle;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.widget.TabHost;
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] AndroidTab [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TabActivity {
[/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]/** Called when the activity is first created. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreate(Bundle savedInstanceState) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onCreate(savedInstanceState);[/LEFT]
setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main2[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE]...
if second Java file have Extends Activity then it all work if its TabActivity it dosen't
any solution to this ?
Code:
Intent myIntent =
new Intent(view.getContext(), Activity2.class); startActivityForResult(myIntent, 0);
That Works?
If not, i would try:
Code:
Intent myIntent =
new Intent(Login.this, Activity2.class); startActivityForResult(myIntent, 0);
€: Do you know how to "transfer" the integer "position" to another class?
Code:
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Intent intent = new Intent(main.this, set.class);
intent.putExtra(null, position);
startActivity(intent);
}
with putExtra?
i fixed my tab switching, i did not have all the activitys in Android Manifest file thats why it was crashing.
now i have a new problem, why cant i chage font colour ?
{
"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"
}
Dear xda members,
a friend and me want to make an app for readmore.de.
Here one screenshot what we got at this moment.
{
"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"
}
Ok, the problem is that we can't login and save cookies for the page.
Here the code
Code:
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost("http://www.readmore.de/index.php?cont=login");
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("email", email));
nvps.add(new BasicNameValuePair("password", password));
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 8096);
String line;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
int iSuche = 0;
iSuche = sb.indexOf("myrmcontainer");
myString = "myrmcontainer gefunden an Stelle " + iSuche + "\n";
myString = myString + "\n" + sb.toString().substring(iSuche);
Some forums says it must work.
The 2nd code we got is
Code:
URLConnection connection = new URL("http://www.readmore.de/index.php?cont=login").openConnection();
connection.setDoOutput(true);
String content =
"email=" + URLEncoder.encode (email) +
"&password=" + URLEncoder.encode (password) +
"&cookie=" + URLEncoder.encode ("true") +
"&login=" + URLEncoder.encode ("Anmelden");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", "" + content.getBytes().length + "");
OutputStream output = connection.getOutputStream();
output.write(content.getBytes());
InputStream stream = connection.getInputStream();
connection.connect();
output.close();
But this does not work too.
Any solutions for this?
Thanks for help
I am sorta having a similar issue, but it pertains to the G2X in particular. I am using HttpUrlConnection which works just fine on the nexus one g1 and emu, but for some reason on this device its behaving differently, I get an IOException but no message. really confused
Hi,
I am making an app which consists of an infinite running service which needs to be stopped when the checkbox is disabled.
i am currently inheriting intentservice class for Myservice class but the problem is is doesn't get stop on clicking the buttons(which calls stopservice) and keeps running, i have tried logging and ondestroy() does gets called but service doesn't stop.
i have Also tried inheriting service class but still same. i am posting the code below.
From MainActivity:
Code:
service.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent= new Intent(MainActivity.this,Myservice.class);
if(sp==false)
{ Log.d("service1", "Startservice invoked");
startService(intent);
sp=true;
}
else if(sp==true)
{
Log.d("service1", "Stopservice invoked");
stopService(intent);
sp=false;
}
return false;
}
});
sp is just a static flag to check whether the checkbox was clicked with initial value as false.(isenabled() method was giving problems)
Myservice code:
Code:
public class Myservice extends IntentService {
public Myservice() {
super("My Service");
}
@Override
protected void onHandleIntent(Intent intent) {
while(true){
Log.d("service1", "Service is running");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Here is a screen shot of the log
{
"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"
}
Hi,
A solution to stop a task via a checkbox is on your 'onclick' function of your checkbox, you need to put a value in the application preference :
HTML:
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = p.edit();
editor.put("yourPreferenceKey",value);
And in your run function of your task :
HTML:
//your task need have the application context in attribute
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
p.getBoolean("yourPreferenceKey",false); //false = default value
USING ANDROID L DIALOG IN YOUR APPS?
EASY
Click to expand...
Click to collapse
{
"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"
}
Hi, my name is Tomer Rosenfeld.
I'm a 15 years old Israeli kid, I love android and especially android L so I figured, why not make android developer's life easier?
So here you go.
A simple to use library to create a android L dialog on any 2.3+ android device in your app using 3 Lines of code!
Once you done following the tutorial in the git readme you will be able to create an android L like dialog with these few lines of code:
Code:
AndroidLDialog dialog = new AndroidLDialog.Builder(ActivityName.this)
.Title("A Title)
.Message("A message)
.setPositiveButton("TEXT" , new View.OnClickListener() {
@Override
public void onClick(View v) {
}
})
.setNegativeButton("CANCEL", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
})
//finally
.show();
Link
GITHUB
P.S
The sexy onclick animation only works for android 3.0 and later so if you are using gingerbread there will be no onclick animation.
Did I help you?
You know, the thanks button is right there...
Full tutorial:
INITIALIZING
1. Clone the repository
2. Copy the dialogL folder to your project root directory
3. Add this project as a dependency as shown below
Code:
dependencies {
compile project(':dialogL')
}
4. Gradle sync and rebuild project
5. Add AndroidLDialog to your code!, see "Instructions"
BASICS
Code:
AndroidLDialog dialog = new AndroidLDialog.Builder(ActivityName.this)
.Title("A Title)
.Message("A message)
.setPositiveButton("TEXT" , new View.OnClickListener() {
@Override
public void onClick(View v) {
}
})
.setNegativeButton("CANCEL", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
})
//finally
.show();
ADVANCED
Changing the dialog background:
Code:
dialog.setBackground(R.drawable.background);
//or
dialog.setBackground(Your Drawable);
//or
dialog.setBackgroundColor(R.color.your_color);
Getting text from the dialog
Code:
String title = dialog.getTitle();
//or
String message = dialog.getMessage();
More customization
Code:
dialog.setTitleColor(getResources().getColor(R.color.your_color);
//or
dialog.setMessageColor(getResources().getColor(R.color.your_color);
//or
dialog.setTitleTextSize(22);
//or
dialog.setMessageTextSize(22);
Hello,
In that tutorial, you are going to learn how to load an external web site into your Android application with Android Studio. To load an external web site into an Android Application, we are going to use the WebView component available in the Android SDK.
{
"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"
}
Note that you can discover this tutorial in video on YouTube :
The first thing to do is to add the internet permission to the Android Manifest because we are going to load data from the network.
In the Java code of the Main Activity, we are going to create a new instance of the WebView object. We enable Javascript on this WebView instance and then, we set a WebViewClient object instance on the WebView.
To avoid some memory leaks with the WebView and its internal state, we don’t forget to call the destroy method of the WebView instance used in the onDestroy method of our Main Activity.
This gives us the following code :
Code:
package com.ssaurel.webview;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.ssaurel.com/blog");
setContentView(webView);
}
@Override
protected void onDestroy(){
super.onDestroy();
if (webView != null) {
webView.destroy();
}
}
}
Last step is to run your Android Application to enjoy the SSaurel’s Blog loaded in a WebView :
To discover more tutorials on Android development, you can subscribe to the SSaurel’s Channel on YouTube : https://www.youtube.com/channel/UCXoh49OXVg1UGjgWX1JRvlw
Don't hesitate to try this tutorial and give me your feedback.
Thanks.
Sylvain