1853 pagesV  1 2 3 4 5 6 > »  
 
REPLY
> Programming Questions | Frequently encountered, sometimes stupid, questions on Android
RubberBigPepper
Message#1
22.08.10, 09:02
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

Attached ImageGoogle Android OS - Programming
Programming Questions � | Android library � | FAQ | Catalog of open source programs for Android OS

Discussion of the subtleties of creating programs for Google Android OS.
When writing code, it must be properly formatted.
[code] and [/ code]

When writing a large code it should be hidden under the spoiler
[SPOILER] spoiler content [/ SPOILER]

������� SDK: download

http://developer.android.com/
Android Scripting Environment (ASE)- create scripts directly on the device running Android OS.

All the best from this theme (it is in the filling mode from 12/05/2017).

And do not act like John.
Attached Image

Be sure to read!
Dear users, due to the lack of psychics, no one can answer the question "Why does the application crash?" or "Why does the application crash / force close?" whenno logs. Therefore, all such questions will be deleted.

Post has been editedSaWSeM - 30.03.19, 12:41
Reason for editing: editing
RubberBigPepper
Message#2
22.08.10, 11:44
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

We continue.
How to find out from the GPS system that it caught the satellites and its valid data and how to get a notification right away if the satellites are lost?


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
thevery
Message#3
22.08.10, 11:51
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper,
high accuracy = satellites, low accuracy = no satellites?
RubberBigPepper
Message#4
22.08.10, 11:55
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

thevery @ 22.8.10, 14:51*
high accuracy = satellites, low accuracy = no satellites?

Like this is wrong.
Is there another way?


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
thevery
Message#5
22.08.10, 13:21
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper,
Must be - all sorts of programs like gps status are able to show the number of satellites
OXOTHuK76
Message#6
23.08.10, 09:18
Guru
*********
[offline]

Group: Friendssavagemessiahzine.com
Messages 2355
Check in: 03.07.10

Reputation:-  297  +

You can something like this ..

final LocationManager lm = (LocationManager) getSystemService (Context.LOCATION_SERVICE);
Criteria criteria = new Criteria ();
criteria.setAccuracy (Criteria.ACCURACY_COARSE);
criteria.setAccuracy (Criteria.ACCURACY_FINE);
final String prov = lm.getBestProvider (criteria, true);

lm.requestLocationUpdates (prov, 0,0, new LocationListener () {
public void onLocationChanged (Location loc) {
lm.removeUpdates (this); // I have a one-time request, so I immediately delete the listener.
}

public void onStatusChanged (String s, int i, Bundle bundle) {
}

public void onProviderEnabled (String s) {
}

public void onProviderDisabled (String s) {
}
});


getBestProvider (criteria, true); returns network or null if GPS is unavailable, or you can omit ACCURACY_COARSE then return either GPS or null.

The LocationManager also has a getGpsStatus () method; it returns the status of the satellites.
And if it is not necessary, you just need to get a position, then the onLocationChanged listener will return a valid location.

Post has been editedOXOTHuK76 - 23.08.10, 09:20
RubberBigPepper
Message#7
23.08.10, 10:01
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

I mean, so I turned on my software, she caught satellites and stuff, the data showed.
Then the user went into the house, the satellites disappeared, here's how to track it?
onLocationChanged simply ceases to be called, therefore it is not clear.
I think to make a stream that will jerk, check when the data came the last time and if more than 2 seconds have passed, then all, assume that the satellites are gone.


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
OXOTHuK76
Message#8
23.08.10, 10:07
Guru
*********
[offline]

Group: Friendssavagemessiahzine.com
Messages 2355
Check in: 03.07.10

Reputation:-  297  +

Well, there is a function getLastKnownLocation or something like that. You take it periodically, you look at the internal timestamp and compare it with the current time.

But for this you need to constantly ask for a position (so that updates to the location would come) otherwise the GPS will simply not be used.

Post has been editedOXOTHuK76 - 23.08.10, 10:08
RubberBigPepper
Message#9
23.08.10, 13:24
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

Okay, leave it behind.
Another problem: it is necessary for the application to respond normally to a change in the orientation of the screen, the option to restart (and at the same time it will be necessary to raise all the settings, pictures, etc., for a long time) does not suit. That is, restarting the Activity is alright, so be it.
Because I write this:
import android.app. *;

public class CRootApplication extends Application
{
/ ** main class of work * /
private static CGPSCore m_cGPSCore;

public CGPSCore getGPSCore ()
{
return m_cGPSCore;
}
@Override
public void onCreate ()
{
super.onCreate ();
m_cGPSCore = new CGPSCore (this); // here you can pick up the entire GPS system, saved states, etc.
}

@Override
public void onTerminate ()
{
m_cGPSCore.StopGPS (this); // here saving states, routes, etc.
super.onTerminate ();
}
}

Management does not come to onTerminate.
What's wrong? Of course, in the manifest, the application class is connected.


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
OXOTHuK76
Message#10
23.08.10, 13:54
Guru
*********
[offline]

Group: Friendssavagemessiahzine.com
Messages 2355
Check in: 03.07.10

Reputation:-  297  +

Should a term be called when the screen is rotated?
RubberBigPepper
Message#11
23.08.10, 14:23
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

OXOTHuK76 @ 23.8.10, 16:54*
Should a term be called when the screen is rotated?

I just do not need that when you rotate the screen, something was caused.
I need it to rise when I launch the application, once everything he needs to read and then work regardless of the orientation of the screen and its change.
But when you exit the application (by the way, how to make the right exit? Call Activity.finish?) It saved all changes once, freed up memory and resources.


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
OXOTHuK76
Message#12
23.08.10, 23:25
Guru
*********
[offline]

Group: Friendssavagemessiahzine.com
Messages 2355
Check in: 03.07.10

Reputation:-  297  +

That would not cut down - you need to strictly indicate the orientation of the portrait or landscape, then in theory should not constantly cut down cut.
In general, there is Google - it is an infection smart - knows everything :)))

Post has been editedOXOTHuK76 - 23.08.10, 23:25
avs234
Message#13
24.08.10, 10:50
Old resident
*******
[offline]

Group: Friendssavagemessiahzine.com
Messages 907
Check in: 26.09.07
Google nexus 4

Reputation:-  304  +

OXOTHuK76 @ 24.8.10, 0:25*
I just do not need that when you rotate the screen, something was caused.

Free presentation of the manual, I hope it will help:

public void onConfigurationChanged (Configuration newConfig): only called if the corresponding bit is set in the configChanges attribute of the manifest.

public static final int configChanges: if the bit is not set (orientation = 0x0080), the activity will * be restarted * with this system configuration change; if set, the activity will continue to work and its Activity.onConfigurationChanged handler will be called (which no one bothers to leave empty).

Activity.finish is like the right method, but this is just a request for completion, not a real equivalent of exit (). I have after him the application could just go into the background and hang there indefinitely (apparently in case it is suddenly needed shortly). I do suicide with the release of resources like this:

android.os.Process.killProcess (android.os.Process.myPid ());
thevery
Message#14
24.08.10, 10:53
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper,
can make it easier to not restart?
onTerminate comes "optional" (for example, when a task killer is killed) and you should not rely on it, better onDestroy

Posted 08/24/2010 10:53 AM:

avs234 @ 24.8.10, 11:50*
I do suicide with the release of resources like this:
android.os.Process.killProcess (android.os.Process.myPid ());

I believe that it is more correct to do
http://developer.android.com/reference/and...va.lang.String)
RubberBigPepper
Message#15
24.08.10, 11:12
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

Thank you all, yesterday I redid it exactly as it was written here, removed Application, put everything into Activiti, set flags so that it would not restart.
So far everything was fine, until I decided to draw a PNG image on the canvas today and stuck it. How to do it? I put the picture in Res \ drawable-ldpi.
I understand your folders for pictures and sounds in res can not be created? (Eklipsa swears if you create a left folder, if inside an existing folder, it passes).
How to raise the bitmap from resources?
Through "public static Bitmap decodeResource (Resources res, int id)"?


And yes, I forgot to say "public void killBackgroundProcesses (String packageName)" does not work, as it requires API 8 and above, I use 4 (Android 1.6).

Post has been editedRubberBigPepper - 24.08.10, 11:17


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
thevery
Message#16
24.08.10, 13:11
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper @ 24.8.10, 12:12*
And yes, I forgot to say "public void killBackgroundProcesses (String packageName)" does not work, as it requires API 8 and above, I use 4 (Android 1.6).

there is another method, literally a line below, see the same class

RubberBigPepper @ 24.8.10, 12:12*
Through "public static Bitmap decodeResource (Resources res, int id)"?

Yes

RubberBigPepper @ 24.8.10, 12:12*
I understand your folders for pictures and sounds in res can not be created?

can not. Folders can only be in assets, alas
RubberBigPepper
Message#17
27.08.10, 20:26
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

Another simple question: how to start a child from the main activation, with settings.
And if it is possible, then how to prohibit exiting the main activation by the "back" button, only through the menu item?


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
thevery
Message#18
27.08.10, 23:14
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper,
Send data via putExtra.
To intercept the button back, but it is not recommended to do so, plus the button with the house is still not intercepted.
RubberBigPepper
Message#19
28.08.10, 08:10
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

Thanks for answers.
Through putExtra can pass your class?
Another question: does the Android have no analogue for NumericUpDown or Buddy? I need a field for entering numbers with two arrows that change the entered number.


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]
thevery
Message#20
28.08.10, 14:18
Guru
*********
[offline]

Group: Developers
Messages 13054
Check in: 22.03.06
Samsung Galaxy S7 SM-G930

Reputation:-  804  +

RubberBigPepper @ 28.8.10, 9:10*
Through putExtra can pass your class?

and this is the audacity to ask RTFM questions:
http://developer.android.com/reference/and...Parcelable.html

RubberBigPepper @ 28.8.10, 9:10*
Another question: does the Android have no analogue for NumericUpDown or Buddy? I need a field for entering numbers with two arrows that change the entered number.

http://maximyudin.blogspot.com/2010/05/numberpicker.html
RubberBigPepper
Message#21
31.08.10, 12:02
Cucumber
*********
[offline]

Group: Developers
Messages 9340
Check in: 29.03.10
Samsung Galaxy A5 (2017) SM-A520F / DS

Reputation:-  1312  +

An analogue of NumericUpDown or Buddy is not an android?

Thanks for the article, but did not accept that in 2.2 does not work.
Therefore, I wrote my Compound Control for these purposes, it can be useful to someone.
Code:
import android.content.Context;
import android.util.AttributeSet;
import android.view. *;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

/ ** Control to select a numeric value from a specified range * /
public class NumericUpDownCtrl extends RelativeLayout implements OnClickListener
{
/ ** maximum value * /
private int m_nMinValue;
/** minimum value*/
private int m_nMaxValue;
/ ** the value itself * /
private int m_nValue;
/ ** increment value button * /
private Button m_cBtnUp;
/ ** decrease value button * /
private Button m_cBtnDown;
/ ** text input field * /
private TextView m_cText;

/ ** the value itself * /
public int getValue ()
{
return m_nValue;
}
/ ** set value * /
public void setValue (int nValue)
{
if (nValue> = m_nMinValue && nValue <= m_nMaxValue)
{
m_nValue = nValue;
m_cText.setText (String.valueOf (m_nValue));
}
}
/ ** the minimum possible value * /
public int getMinimum ()
{
return m_nMinValue;
}
/ ** set the minimum value * /
public void setMinimum (int nMinimum)
{
if (nMinimum> = m_nMaxValue)
return; // wrong value
m_nMinValue = nMinimum;
if (m_nValue setValue (m_nMinValue);
}
/ ** maximum possible value * /
public int getMaximum ()
{
return m_nMaxValue;
}
/ ** set the maximum value * /
public void setMaximum (int nMaximum)
{
if (nMaximum <= m_nMinValue)
return; // wrong value
m_nMaxValue = nMaximum;
if (m_nValue> m_nMaxValue) // adjust the value
setValue (m_nMaxValue);
}
/ ** simple constructor * /
public NumericUpDownCtrl (Context context)
{
super (context);
m_cBtnUp = null;
m_cBtnDown = null;
m_cText = null;
Initialize (context);
}
/ ** constructor with attributes * /
public NumericUpDownCtrl (Context context, AttributeSet attrs)
{
super (context, attrs);
m_cBtnUp = null;
m_cBtnDown = null;
m_cText = null;
Initialize (context);
}
/ ** initialization, placement of controls * /
private void Initialize (Context context)
{
try
{
m_nMinValue = 0;
m_nMaxValue = 100;
m_nValue = m_nMinValue;
if (context == null)
return;
// create controls, customize, subscribe to their events
m_cBtnUp = new Button (context);
m_cBtnUp.setOnClickListener (this);
m_cBtnUp.setText ("+");
m_cBtnUp.setId (1000); // without ID does not work in steering wheels
m_cBtnDown = new Button (context);
m_cBtnDown.setOnClickListener (this);
m_cBtnDown.setText ("-");
m_cBtnDown.setId (2000); // without ID does not work in steering wheels
m_cText = new EditText (context);
m_cText.setText (String.valueOf (m_nValue));
m_cText.setEnabled (false);
// place controls
RelativeLayout.LayoutParams cLParam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PA
RENT);
cLParam.addRule (RelativeLayout.ALIGN_PARENT_LEFT);
addView (m_cBtnDown, cLParam);
cLParam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PA
RENT);
cLParam.addRule (RelativeLayout.ALIGN_PARENT_RIGHT);
addView (m_cBtnUp, cLParam);
cLParam = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PA
RENT);
cLParam.addRule (RelativeLayout.CENTER_HORIZONTAL);
cLParam.addRule (RelativeLayout.CENTER_VERTICAL);
cLParam.addRule (RelativeLayout.RIGHT_OF, m_cBtnDown.getId ());
cLParam.addRule (RelativeLayout.LEFT_OF, m_cBtnUp.getId ());
addView (m_cText, cLParam);
}
catch (Exception ex)
{

}
}

@Override
/ ** button click handler * /
public void onClick (View v)
{
if (v == m_cBtnUp)
{// press the zoom button
setValue (getValue () + 1);
}
if (v == m_cBtnDown)
{// pressed the decrease button
setValue (getValue () - 1);
}
}
}


--------------------
VideoReg , LG camera
Displaybrightness, [url = "//savagemessiahzine.com/forum/index.php?showtopic=220775"В® WiFi TX power [/ ur]

1853 pagesV  1 2 3 4 5 6 > » 


 mobile version    Now: 04/29/19 04:50