You should use String(int i)
lblAnswer.text = String(bloodglucose + 100);
Update: What about something like this:
var i:int = bloodglucose + 100;
var s:String = String(i);
lblAnswer.text = s;
.
stackoverflow.comm
You should use String(int i)
lblAnswer.text = String(bloodglucose + 100);
Update: What about something like this:
var i:int = bloodglucose + 100;
var s:String = String(i);
lblAnswer.text = s;
stackoverflow.comm
I am trying to develop a simple Android application that can record audio from the microphone, then stream that data to a server for playback. The solution needs to run on Gingerbread and later and has to work over 3G (so no wi-fi only methods).
So far I have Googled for sample applications that can get me this functionality and come up empty-handed. Most tutorials assume streaming from the server or PC to a device, this is the opposite of what I am trying to accomplish.
Can anyone give me sample code for an app that records mic audio, streams it to a simple server app, and does it all in a way that minimizes audio gaps, delay, and other audio transmission issues?
Edit-- Things I have tried so far: SIP (stack not enabled on some phones, no free SIP stack for commercial use), AudioRecord (don't know how to compress audio), MediaRecorder (can never seem to connect to the remote port), and straight socket programming (very poor sound quality). I'd love to make any of these methods work... maybe I am missing something. Is there a "best practices" way for Android to server audio streaming? I will post the complete code solution when I solve this problem :-)
stackoverflow.comm
I have helped from the book Pro Android media...
Here is the code:
public class MicMeter extends Activity implements OnClickListener {
RecordAudio recordTask;
int blocksize = 256;
int frequency = 8000;
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
TextView txt;
Button start;
boolean started = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mic_meter);
start = (Button)findViewById(R.id.button1);
txt = (TextView)findViewById(R.id.textView1);
start.setOnClickListener(this);
}
private class RecordAudio extends AsyncTask{
@Override
protected Void doInBackground(Void... params) {
try{
int bufferSize = AudioRecord.getMinBufferSize(frequency,channelConfig,audioEncoding);
AudioRecord audioRecord = new AudioRecord( MediaRecorder.AudioSource.MIC, frequency, channelConfig, audioEncoding, bufferSize);
short[] buffer = new short[blocksize];
double[] meter = new double[blocksize];
audioRecord.startRecording();
while(started){
int bufferReadResult = audioRecord.read(buffer, 0, blocksize);
for (int i = 0; i < blocksize && i < bufferReadResult; i++) {
meter[i] = (double) buffer[i] / 32768.0; // signed 16 bit
}
publishProgress(meter);
}
audioRecord.stop();
}catch (Throwable t) {
Log.e("AudioRecord","RecordingFail");
}
return null;
}
@Override
protected void onProgressUpdate(double[]... meter) {
for(int i = 0 ; i < meter[0].length ; i++){
double helper = i;
txt.setText(Double.toString(helper));
}
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(started){
recordTask.cancel(true);
}else{
started = true;
recordTask = new RecordAudio();
recordTask.execute();
}
}
}
while i press the button. It shows 255.0 and then it doesn't response... Are there any way to fix it?? Are there any beter version about this?
thank
stackoverflow.comm
I have override my WebChromeClient's onJsAlert behavior like:
WebChromeClient wvcc = new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
//...
return true;
}
}
my application successfully handle the Js alerts and suppressed the original alert. However, after the alert event, I can no long click my buttons(in list-items of listview) on the web page in my webview. I am currently using jquery mobile to build my web.
Is there anything else I should aware of?
stackoverflow.comm
I was really confused about this topic, so I had to ask. Being new on Android, I was thinking of creating an introductory sort of tutorial like page for the app I am working on, like the one's you see on various apps that is used for the first time in which they point out various features of the app, what functionality does this button perform when pressed, what does the menu item do, in a sort of a dynamic way. What are these actually ?? Are they | |||
default
stackoverflow.comm
I need some help understanding the fundamentals of scrolling over items that are drawn to a canvas in Android. Suppose I want to create a timeline where time at 0 is the top of a visualization and as time increased the timeline continues to be rendered below the previous point. If I wish to render this on Android I know I could simply create a bunch of items on a canvas by overriding onDraw(). However, let's suppose the visualization is bigger than the screen allows.
For example in the first picture below the large black box contains the entire canvas as I render it. I create a blue line that runs vertically up and down as well as several yellow, green and blue rectangles. The red box represents the screen of the Android that is rendering the visualization. As it initially opens all items are drawn but only the items contained within the red box show up on the screen.
Now if the user is to scroll down, items that initially appeared below the red box are in view while items that have gone out of the confines of the red box are no longer visable, as represented in the second picture.
I believe I need to use scrollables but I'm quite lost how to do so. I've read over this page http://developer.android.com/training/custom-views/custom-drawing.html explaining how to create your own customer images and this page http://developer.android.com/training/custom-views/making-interactive.html explaining how to make the UI interactive, but I think I'm missing something.
A sample code that illustrates this problem (this is basic, assume there is logic dictating WHERE the boxes/lines go, etc.) is as follows:
package com.example.scrolltest;
import com.example.scrolltest.Draw;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
public class MainActivity extends Activity {
Draw draw;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
draw = new Draw(this);
draw.setBackgroundColor(Color.WHITE);
setContentView(draw);
}
}
and
package com.example.scrolltest;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class Draw extends View {
Paint paint = new Paint();
public Draw(Context context) {
super(context);
}
@Override
public void onDraw(Canvas canvas) {
paint.setColor(Color.GREEN);
canvas.drawRect(30, 30, 90, 200, paint);
paint.setColor(Color.BLUE);
canvas.drawLine(100, 20, 100, 1900, paint);
paint.setColor(Color.GREEN);
canvas.drawRect(200, 2000, 400, 3000, paint);
}
}
stackoverflow.comm
I have a search dialog which needs to be suggestion enabled from the database as shown here http://developer.android.com/images/search/search-suggest-custom.png.
My search dialog will be shown at the top, when i click an action bar menu item. When the user starts typing in some text, it should search the db and display suggestions accordingly. As of now, i have a search dialog, but when the user types in some text, no suggestions are displayed.
my content provider:
public class MyCustomSuggestionProvider extends ContentProvider {
SQLiteDatabase db;
SQLiteQueryBuilder qb;
String sqlTables = "countries";
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public boolean onCreate() {
return false;
}
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
MyDatabase myDB = new MyDatabase(getContext());
db = myDB.getReadableDatabase();
Cursor c = null;
if (selectionArgs != null && selectionArgs.length > 0
&& selectionArgs[0].length() > 0) {
qb = new SQLiteQueryBuilder();
String[] sqlSelect = { "name" };
qb.setTables(sqlTables)
c = qb.query(db, null, selection, selectionArgs, null, null,
null);
c.moveToFirst();
} else {
return null;
}
return c;
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
return 0;
}
}
my manifest:
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Visa" >
android:name="com.m7.visa.contentprovider.MyCustomSuggestionProvider"
android:authorities="com.m7.visa.contentprovider.MyCustomSuggestionProvider" >
android:name="com.m7.visa.MainActivity"
android:label="@string/app_name" >
android:name="android.app.searchable"
android:resource="@xml/searchable" />
my searchable configuration:
android:hint="hint..."
android:label="@string/app_name"
android:searchSuggestAuthority="com.m7.visa.contentprovider.MyCustomSuggestionProvider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestSelection=" ?" >
any idea where am i going wrong?
stackoverflow.comm
I am developing an application that shows the different photos from server and user can set selected photos as wallpaper of its device i used given code to set wallpaper it working but image was not set properly it not fit to screen. I used this code.
Please help me out. | |||
You can try resizing your bitmap like this
| |||
To set wallpaper in android use below code: By using WallpaperManager Class
| |||
default
stackoverflow.comm
I can't figure out why my app is forceclosing when i turn off the screen, this is the logcat My app has scrolling text, displays widgets, gets user location, has a pager, gets the current time, gets the battery level, so the code is pretty long so for now i'll post only the logcat, maybe you can figure something out just with that If you need some pieces of code let me know
04-09 02:57:56.498: D/Evolution Launcher(16574): Stopping
04-09 02:57:56.623: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection
04-09 02:57:56.639: W/IInputConnectionWrapper(16574): getTextBeforeCursor on inactive InputConnection
04-09 02:57:56.655: W/IInputConnectionWrapper(16574): getSelectedText on inactive InputConnection
04-09 02:57:56.662: W/IInputConnectionWrapper(16574): getTextAfterCursor on inactive InputConnection
04-09 02:57:56.670: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection
04-09 02:57:56.670: W/IInputConnectionWrapper(16574): getTextBeforeCursor on inactive InputConnection
04-09 02:57:56.850: D/dalvikvm(16574): GC_EXPLICIT freed 1120K, 6% free 20548K/21696K, paused 3ms+13ms, total 140ms
04-09 02:57:56.959: W/IInputConnectionWrapper(16574): getExtractedText on inactive InputConnection
04-09 02:57:57.053: W/ResourceType(16574): Failure getting entry for 0x7f030004 (t=2 e=4) in package 0 (error -75)
04-09 02:57:57.053: D/AndroidRuntime(16574): Shutting down VM
04-09 02:57:57.053: W/dalvikvm(16574): threadid=1: thread exiting with uncaught exception (group=0x41356930)
04-09 02:57:57.069: E/AndroidRuntime(16574): FATAL EXCEPTION: main
04-09 02:57:57.069: E/AndroidRuntime(16574): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.doublep.evolution/com.doublep.evolution.LauncherActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3692)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.access$700(ActivityThread.java:141)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.os.Looper.loop(Looper.java:137)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-09 02:57:57.069: E/AndroidRuntime(16574): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 02:57:57.069: E/AndroidRuntime(16574): at java.lang.reflect.Method.invoke(Method.java:511)
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-09 02:57:57.069: E/AndroidRuntime(16574): at dalvik.system.NativeStart.main(Native Method)
04-09 02:57:57.069: E/AndroidRuntime(16574): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.getValue(Resources.java:1014)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2139)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.content.res.Resources.getLayout(Resources.java:853)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Activity.setContentView(Activity.java:1881)
04-09 02:57:57.069: E/AndroidRuntime(16574): at com.doublep.evolution.LauncherActivity.onCreate(LauncherActivity.java:455)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Activity.performCreate(Activity.java:5104)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-09 02:57:57.069: E/AndroidRuntime(16574): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-09 02:57:57.069: E/AndroidRuntime(16574): ... 12 more
04-09 02:57:57.116: I/Process(16574): Sending signal. PID: 16574 SIG: 9
I've changed the setContentView to a different layout (different file, copied content from the old one) and it gives me a different forceclosing
04-09 03:34:25.514: D/dalvikvm(18864): GC_EXPLICIT freed 1259K, 6% free 20440K/21728K, paused 2ms+7ms, total 36ms
04-09 03:34:28.553: D/Evolution Launcher(18864): Stopping
04-09 03:34:28.756: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:28.772: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection
04-09 03:34:28.780: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:28.787: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:28.795: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:28.795: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:28.803: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection
04-09 03:34:28.803: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection
04-09 03:34:28.811: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:28.819: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:28.819: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection
04-09 03:34:28.826: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): beginBatchEdit on inactive InputConnection
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): endBatchEdit on inactive InputConnection
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:28.834: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:28.842: W/IInputConnectionWrapper(18864): getSelectedText on inactive InputConnection
04-09 03:34:28.842: W/IInputConnectionWrapper(18864): getTextAfterCursor on inactive InputConnection
04-09 03:34:28.858: W/IInputConnectionWrapper(18864): beginBatchEdit on inactive InputConnection
04-09 03:34:28.858: W/IInputConnectionWrapper(18864): endBatchEdit on inactive InputConnection
04-09 03:34:29.569: D/dalvikvm(18864): GC_FOR_ALLOC freed 1154K, 7% free 21232K/22604K, paused 51ms, total 66ms
04-09 03:34:29.819: D/dalvikvm(18864): GC_FOR_ALLOC freed 201K, 7% free 23846K/25416K, paused 25ms, total 25ms
04-09 03:34:30.170: D/dalvikvm(18864): GC_FOR_ALLOC freed 3K, 6% free 26556K/28128K, paused 21ms, total 24ms
04-09 03:34:30.420: D/Evolution Launcher(18864): Loading variables
04-09 03:34:30.420: D/Evolution Launcher(18864): Restoring prefs
04-09 03:34:30.420: D/Evolution Launcher(18864): Screen density actions
04-09 03:34:30.467: W/IInputConnectionWrapper(18864): getExtractedText on inactive InputConnection
04-09 03:34:30.475: I/Choreographer(18864): Skipped 71 frames! The application may be doing too much work on its main thread.
04-09 03:34:30.631: E/ActivityThread(18864): Activity com.doublep.evolution.LauncherActivity has leaked IntentReceiver com.doublep.evolution.LauncherActivity$4@42858a78 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-09 03:34:30.631: E/ActivityThread(18864): android.app.IntentReceiverLeaked: Activity com.doublep.evolution.LauncherActivity has leaked IntentReceiver com.doublep.evolution.LauncherActivity$4@42858a78 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:795)
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:596)
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1316)
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1296)
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1290)
04-09 03:34:30.631: E/ActivityThread(18864): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:423)
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity.batteryLevel(LauncherActivity.java:144)
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity.access$0(LauncherActivity.java:116)
04-09 03:34:30.631: E/ActivityThread(18864): at com.doublep.evolution.LauncherActivity$1.run(LauncherActivity.java:985)
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Handler.handleCallback(Handler.java:725)
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Handler.dispatchMessage(Handler.java:92)
04-09 03:34:30.631: E/ActivityThread(18864): at android.os.Looper.loop(Looper.java:137)
04-09 03:34:30.631: E/ActivityThread(18864): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-09 03:34:30.631: E/ActivityThread(18864): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 03:34:30.631: E/ActivityThread(18864): at java.lang.reflect.Method.invoke(Method.java:511)
04-09 03:34:30.631: E/ActivityThread(18864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-09 03:34:30.631: E/ActivityThread(18864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-09 03:34:30.631: E/ActivityThread(18864): at dalvik.system.NativeStart.main(Native Method)
04-09 03:34:30.701: W/IInputConnectionWrapper(18864): getTextBeforeCursor on inactive InputConnection
04-09 03:34:30.701: D/AndroidRuntime(18864): Shutting down VM
04-09 03:34:30.701: W/dalvikvm(18864): threadid=1: thread exiting with uncaught exception (group=0x41356930)
04-09 03:34:30.709: E/AndroidRuntime(18864): FATAL EXCEPTION: main
04-09 03:34:30.709: E/AndroidRuntime(18864): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) } in com.doublep.evolution.LauncherActivity$4@42858a78
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Handler.handleCallback(Handler.java:725)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Handler.dispatchMessage(Handler.java:92)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.os.Looper.loop(Looper.java:137)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-09 03:34:30.709: E/AndroidRuntime(18864): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 03:34:30.709: E/AndroidRuntime(18864): at java.lang.reflect.Method.invoke(Method.java:511)
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-09 03:34:30.709: E/AndroidRuntime(18864): at dalvik.system.NativeStart.main(Native Method)
04-09 03:34:30.709: E/AndroidRuntime(18864): Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.doublep.evolution.LauncherActivity$4@42858a78
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:657)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1339)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:445)
04-09 03:34:30.709: E/AndroidRuntime(18864): at com.doublep.evolution.LauncherActivity$4.onReceive(LauncherActivity.java:121)
04-09 03:34:30.709: E/AndroidRuntime(18864): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:758)
04-09 03:34:30.709: E/AndroidRuntime(18864): ... 9 more
04-09 03:34:30.741: I/Process(18864): Sending signal. PID: 18864 SIG: 9
Where you see the log "Stopping" it's when i turn off the screen, where you see "loading variables" it's in the onCreate, so it mean this time it's restarting but crashes anyways
This is how my layout looks like
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img_bkg" >
android:id="@+id/central"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" >
android:id="@+id/custom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" >
android:id="@+id/btn_1_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" >
android:id="@+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_1" />
android:id="@+id/img_icon1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_1" />
android:id="@+id/btn_2_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_1_holder" >
android:id="@+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_2" />
android:id="@+id/img_icon2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_2" />
android:id="@+id/custom2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" >
android:id="@+id/btn_3_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" >
android:id="@+id/btn_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_3" />
android:id="@+id/img_icon3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_3" />
android:id="@+id/btn_4_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_3_holder" >
android:id="@+id/btn_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_4" />
android:id="@+id/img_icon4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_4" />
android:id="@+id/central_console"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/img_back" >
android:id="@+id/buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="3dp" >
android:id="@+id/btn_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_tel" />
android:id="@+id/btn_voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_toRightOf="@id/btn_call"
android:background="@drawable/img_transparent"
android:fitsSystemWindows="true"
android:src="@drawable/btn_voice" />
android:id="@+id/btn_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btn_call"
android:layout_margin="2dp"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_nav" />
android:id="@+id/btn_media"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btn_voice"
android:layout_margin="2dp"
android:layout_toRightOf="@id/btn_navigation"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_media" />
android:id="@+id/outer_ring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clickable="true"
android:src="@drawable/img_outer_ring"
android:visibility="visible" />
android:id="@+id/arcViewContainer"
android:layout_width="457px"
android:layout_height="457px"
android:layout_centerInParent="true" >
android:id="@+id/arcView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_central_ring" />
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:focusable="false"
android:longClickable="true"
android:text="@+string/time"
android:textColor="#ffffff"
android:textSize="57dp"
android:visibility="visible" />
android:id="@+id/pager"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_centerInParent="true" >
android:id="@+id/notification_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_battery_low"
android:visibility="gone" />
android:id="@+id/reflection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/img_reflection" />
android:id="@+id/drop_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="@drawable/img_drop_left"
android:visibility="gone" />
android:id="@+id/drop_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/img_drop_right"
android:visibility="gone" />
android:id="@+id/btn_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/img_settings_icon" />
android:id="@+id/btn_trip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_trip" />
android:id="@+id/btn_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/img_transparent"
android:src="@drawable/btn_info" />
android:id="@+id/lcd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/central"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:layout_toLeftOf="@id/btn_info"
android:layout_toRightOf="@id/btn_trip"
android:background="@drawable/leds" >
android:id="@+id/lcd_screen"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/img_lcd2" >
android:id="@+id/txt_lcd_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="marquee"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#f82424"
android:textSize="30dp" />
stackoverflow.comm
I am certainly not a lawyer, but I am pretty sure, that you can't monetize content from a website without their permission. Also this site is not for law-specific questions. – Ahmad 4 mins ago | |
I don't see why you shouldn't be able to, but as a consumer, I would discard your app pretty quickly. If you're charging me money to enable me to make a purchase later, you're just greedy. I doubt you'll make the money back you'll spend implementing that "feature". – 323go 1 min ago |
stackoverflow.comm
Recently I met a strange problem,I start a activity from a service,but if I follow the steps :
after above steps,the activity starts more slowly than normal way.Because I add a log in Activity's onCreate method. normal way is same as above,except pressing home key. Please help me solve it.Thanks. | ||||
You can run the service and activity in different processes. Use the process attribute for service in AndroidManifest.xml Here's a snippit from the docs:
| |||
If you started from the IDE, hit back, and then tapped the launcher icon, you will be starting another instance of your app. This might help explain things. | |||
default
stackoverflow.comm
Change:
b.setItems(types, new OnClickListener){
To
b.setItems(types, new DialogInterface.OnClickListener){
And you will have to split
String[] types = {"1", "2", "3"};
to individual ints, or a CharSequence array.
You probably have an OnClickListener for another normal View in your code somewhere, and have it in your imports. As all OnClickListener classes share the same name, Eclipse auto resolves them all to the currently imported one. You can specify the parent class in such cases.
Additionally, the setItems() method that Eclipse has resolved takes a single int for the first parameter, not a String array. You could use the other setItems() method though, which takes a CharSequence Array. In such a case, change
String[] types = {"1", "2", "3"};
to
CharSequence[] types = {"1", "2", "3"};
stackoverflow.comm
ive seen a post before and i tried to copy and implement it on my porject but i have trouble doing so this is the link that im talking about How do I create a header or footer button bar for my Android application it is on implementing header and footer my problem is that i cant put on my activity in the middle how can i do it in all my activity here is the code for my activity main activity import android.os.Bundle;
@SuppressWarnings("deprecation")
public class ShareAnews extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanews);
TabHost tabhost = (TabHost) findViewById(android.R.id.tabhost);
TabSpec Tab1 = tabhost.newTabSpec("tab1");
TabSpec Tab2 = tabhost.newTabSpec("tab2");
TabSpec Tab3 = tabhost.newTabSpec("tab3");
TabSpec Tab4 = tabhost.newTabSpec("tab4");
Tab1.setIndicator("Traffic").setContent(new Intent(this,ShareAnewsTraffic.class));
Tab2.setIndicator("Accident").setContent(new Intent(this,ShareAnewsAccident.class));
Tab3.setIndicator("Hazard").setContent(new Intent(this,ShareAnewsHazard.class));
Tab4.setIndicator("Crime").setContent(new Intent(this,ShareAnewsCrime.class));
tabhost.addTab(Tab1);
tabhost.addTab(Tab2);
tabhost.addTab(Tab3);
tabhost.addTab(Tab4);
}
}
1st activity
import android.app.Activity;
public class ShareAnewsHazard extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewshazard);
}
}
2nd activity
import android.app.Activity;
public class ShareAnewsTraffic extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewstraffic);
}
}
3rd activity
import android.app.Activity;
public class ShareAnewsAccident extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewsaccident);
}
}
4th activity
import android.app.Activity;
public class ShareAnewsCrime extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewscrime);
}
}
stackoverflow.comm
I've research so many codes and yet my simple 3gpp video wo'nt play or work in the emulator when i clicked the button.
My question is why does my video view wont run? In log cat it shows many errors in AndroiRuntime.
Heres my manifest :
android:name=".TutorialFive"
android:label="@string/app_name"
>
Heres the xml :
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >android:id="@+id/video1"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Heres the java code:
VideoView vid = (VideoView) findViewById(R.id.bThree);
// to set the path of the video
String urlpath = "android.resource://" + getPackageName() + "/"
+ R.raw.xai;
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(vid);
vid.setMediaController(mediaController);
vid.setVideoURI(Uri.parse(urlpath));
vid.start();
stackoverflow.comm
I am building an Android app that is hosted on a server outside Google Play. I need the app to check for new version and prompt user to update when the app starts.
I built a mechanism to check for new version (the app checks for a file on server and compares version) which is working well. Then I prompt user to update, but if user chooses to proceed with the update, I'm not able to trigger the download and installation of the apk.
I tried simply opening the apk url:
window.open(apkURL);
where the apkURL is the full http link to the .apk file hosted on server.
But it doesn't seem to do anything.
I've been researching but I don't find an answer on how to do this. I found some suggestions using native code, like this post Install Application programmatically on Android but I don't know how to do that from within my Phonegap app. Is this the right way to trigger the update? How can something like this be done from within a Phonegap app?
Thanks!
stackoverflow.comm
If I don't run pro-guard on my project, everything is fine but if I run pro-guard and install .apk in device, I am getting above error. I tried adding following lines in proguard-android.txt
file
-keep public class twitter4j.conf.PropertyConfigurationFactory
-dontwarn twitter4j.**
but no luck.
I am using default proguard-android.txt
file from sdk.
I had a look at this link for same issue but could not understand that.
So, could anybody please tell me what is wrong here?
Thanks
stackoverflow.comm
The problem I am facing is due to
It only unchecks this option from settings but the problem remains the same. It make effect when we restart the device. | ||||
default
stackoverflow.comm
I am trying to get location using GPS provider
or Network provider
but i didn't get location from either GPS or Network.
Here is my code which was working fine some days ago but now it's not working.
I don't understand where i am wrong because all permission are already added in AndroidManifest.xml.
Here is the code which helpful for you to understand.
public class SearchDishoom extends Header implements LocationListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchdish);
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000000, 100, this);
locationListenerNetwork = new LocationListener() {
public void onLocationChanged(Location location) {}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
// if gps provider is not enable then popup alertbox
buildAlertMessageNoGps();
} else {
// if gps is one then start searching
locationListenerGps = new LocationListener() {
public void onLocationChanged(Location location) {}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000000,100, locationListenerGps);
}
}
/*
* Get location (lat-long) from sharedpreference to further use
*/
prefLocation = getSharedPreferences("myLocation", MODE_WORLD_READABLE);
String userLocationLat1 = prefLocation.getString("Lat", String.valueOf(0));
String userLocationlong1 = prefLocation.getString("Long", String.valueOf(0));
String address = prefLocation.getString("Address", "Location not found not found");
userLocationLat = Double.parseDouble(userLocationLat1);
userLocationlong = Double.parseDouble(userLocationlong1);
// set lat-long value in getset class for use of another activity
gs = new GetSet();
gs.setLatitude(userLocationLat);
gs.setLangitude(userLocationlong);
if (userLocationLat == 0 && userLocationlong == 0 && address.equals("")) {
/*
* if lat-long is 0 or null then start searching using
* GPS Provider or Network Provider
*/
manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
buildAlertMessageNoGps();
} else {
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000000,100, locationListenerGps);
}
} else {
// set lat-long value in getset class for use of another activity
gs.setLatitude(userLocationLat);
gs.setLangitude(userLocationlong);
setLocationName(userLocationLat, userLocationlong);
}
}
Here is override onLocationchanged():
@Override
public void onLocationChanged(Location location) {
userLocationLat =location.getLatitude();
userLocationlong =location.getLongitude();
prefLocation = getSharedPreferences("myLocation", MODE_WORLD_READABLE);
SharedPreferences.Editor prefsEditor = prefLocation.edit();
prefsEditor.putString("Lat", String.valueOf(userLocationLat));
prefsEditor.putString("Long", String.valueOf(userLocationlong));
gs.setLatitude(userLocationLat);
gs.setLangitude(userLocationlong);
List addresses;
try {
addresses = new Geocoder(SearchDishoom.this, Locale.getDefault())
.getFromLocation(userLocationLat, userLocationlong, 1);
Address obj = addresses.get(0);
add = obj.getAddressLine(0);
city = obj.getLocality();
addressString = add + "," + city;
gs.setCurrentAddressString(addressString);
prefsEditor.putString("Address", addressString);
prefsEditor.commit();
tvLocation.setText(add + "," + city);
} catch (IOException e) {
showToast("Unable to find location");
}
}
Even i am not getting location using Geocoder
, If i enter city name then it show me "Unable to find location".
Here is trick, GeoCoder
is working on Emulator but not working on phone(i tried 2 different handset).
My project is build in API 17
and no any logcat error.
Please give me any hint or reference.
stackoverflow.comm
Any ideas why I get this error when I call
Yet my AndroidManifest.xml has the following within the
| |||
No idea why this should be the case but a project clean did the trick (I added the code to the manifest days ago and cleaned several times since) | |||
default
stackoverflow.comm
I made some buttons and i want to change to another activity when that button1 is clicked. but it won't find my viewImave.class
I'm
This is my MainActivity.java
package com.example.image;
import android.os.Bundle;
import android.view.View.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;
import android.widget.ImageView;
public class MainActivity extends Activity implements OnClickListener {
Toast toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button1 = (Button)findViewById(R.id.button1);
button1.setText("take Image");
button1.setOnClickListener(this);
final Button button2 = (Button)findViewById(R.id.button2);
button2 = (Button)findViewById(R.id.button2);
button2.setText("take Image2");
benter code hereutton2.setOnClickListener(this);
}
@Override
public void onClick (View v) {
if(v.getId()==R.id.button1){
Intent showimageIntent = new Intent(this, ViewImave.class);
startActivity(showimageIntent);
}
else if(v.getId()==R.id.button2)
{
toast = Toast.makeText(this, "onclickbutton2", Toast.LENGTH_SHORT);
toast.show();
}
else{
toast = Toast.makeText(this, "error", Toast.LENGTH_SHORT);
toast.show();
}
}
}
This is my ViewImave.java
package com.example.image;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import android.app.Activity;
import android.view.Menu;
public class ViewImave extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {//
setContentView(R.layout.showimage);
Toast toast = Toast.makeText(this, "newimage oncreate", Toast.LENGTH_SHORT);
toast.show();
}
}
This is showimage.xml
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/koala" />
This is activity_main.xml
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button"
/>
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/button1"
android:text="Button" />
stackoverflow.comm
Hello Gentlemen. Sorry to disturb you with a noob question but I cannot solve it for the life of me and I have tried everything I could find on the forums. I have an Aluratek Cinepad AT107F. I have successfully rooted it. I have full super user permissions and I have no problems deleting any files or folders EXCEPT one directory. Let me explain the situation.
I recently did a firmware update and it included brand new APKs for Youtube, also added Google Play Support, and added Angry Birds.
I am unable to update Youtube to the latest version. It gives a "Package file was not signed correctly. Uninstall the previous copy of the app and try again.".
So I attempted to do just what it had asked. I rooted just to do this. I tried removing it with Titanium Backup, I tried Root Uninstaller, I tried Root Explorer, I tried deleting using the "adb shell rm" command. I still get a "Read-only file system".
Even though I have root and granted root access to Root Explorer, I am unable to change the permissions for this /oem/apps/ directory. It's on the top level of the internal memory. I have no external SD card.
I've spent 10+ hours trying to figure this out and I'm sure someone knows something that I don't and can fix this super easy. I'm asking for your help, you're my only hope!
forum.xda-developers.com
Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...