Related
we have ported some android version. firstly we ported 2.1 AOSP and we have this problem: when i call a phone number, it is not dialing. i can send sms, everybody can call me, and when i press to end call button, its says "hanging up" and it can be stay for hours. some defferences between stock Sony ericsson rom and AOSP this:
S.E .
I/ActivityManager( 1179): Starting activity: Intent { act=android.intent.action.VIEW dat=tel: flg=0x10000000 cmp=com.sonyericsson.dialer/.CallHistoryTabActivity }
I/ActivityManager( 1179): Starting activity: Intent { act=android.intent.action.CALL_PRIVILEGED dat=tel:1430 flg=0x10800000 cmp=com.android.phone/.PrivilegedOutgoingCallBroadcaster }
I/ActivityManager( 1179): Starting activity: Intent { act=android.intent.action.CALL dat=tel:1430 flg=0x10000000 cmp=com.android.phone/.SemcInCallScreen (has extras) }
V/SemcInCallScreen( 1251): onNewIntent: intent=Intent { act=android.intent.action.CALL dat=tel:1430 flg=0x10c00000 cmp=com.android.phone/.SemcInCallScreen (has extras) }
aosp
I/ActivityManager( 1181): Starting activity: Intent { act=android.intent.action.CALL_PRIVILEGED dat=tel:1430 flg=0x10000000 cmp=com.android.phone/.PrivilegedOutgoingCallBroadcaster }
I/ActivityManager( 1181): Starting activity: Intent { act=android.intent.action.CALL dat=tel:1430 flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras) }
i think this difference is in framework.jar and in RIL.smali, but we cant solve it :/ please help us.!(sony ericsson is stopped developing 2.1+ android, so we stuck at is)
Right so I've created a very basic widget. It does nothing but display some text. The mechanics to setting it up are easy to learn. Now that I've learnt that I have to move on to what I actually want my widget to do. That would be where the database is involved. I want it to pull data from a database and have it show on my widget.
Eventually I will progress it so that the user can tap on it to bring up another bit of data from the database or just have a button do it. Right now though I just need to just get the data to show up. Let's say I have 500 rows, well I want the database to pull 1 row at random.
You don't need to tell me about the basics of a database because I already know that, I've used SQLite and all that, it's just getting it to work with a AppWidgetProvider that I can't get.
In fact I can already pull a random row from a database but I've only done it in an Activity. So how do I do this for a widget? Hopefully somoene here has experience with widgets!
I would really appreciate any help, thanks!
I used RemoteViews to manipulate/access my widget buttons from the provider. I'm not sure what type of view you are working with but look those up. It may be what you are looking for.
zalez said:
I used RemoteViews to manipulate/access my widget buttons from the provider. I'm not sure what type of view you are working with but look those up. It may be what you are looking for.
Click to expand...
Click to collapse
Interesting. I'll look into that. I saw some bits of code with RemoteViews but I have no idea about them so I better get learning.
Any chance there are some decent tutorials out there? I get the idea that a RemoteView is what handles the communication for the UI but I still don't get how I can pull data with that involved.
I mean would this work for example: http://stackoverflow.com/questions/5661815/app-with-widget-accesing-to-database?rq=1
I've seen some with tonnes of code and then there's the one above which only has a few lines.
When I went through this, I didn't find any tutorials so I pushed through it myself. Do you have a class to do your database queries?
Using a remote view to change the text you could use something like this inside your onUpdate:
Code:
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); //set your widget layout
remoteViews.setImageViewResource(R.id.btnToggle, R.drawable.toggle_off); //this changes the image in the imageview btnToggle, remoteViews lets you use setText and a couple of other to manipulate certain widget items
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
This is just a quick example pulled from one of my apps, you could put the database function above it to grab the line of text you want and then set the text in the remote view. The updateAppWidget will update all widgets with this view so if you have multitple different widgets then you'll need to pass the specific widgetId rather then the array.
If you want it to update with a button press on the widget, I would advice you set a pending intent which launches a service, does what you need it to do and then the service update the widget using remote views much like the above code.
Hope that helps
zalez said:
When I went through this, I didn't find any tutorials so I pushed through it myself. Do you have a class to do your database queries?
Click to expand...
Click to collapse
I am using the AppWidgetProvider to carry on my database query, within the onUpdate method. I have posted my code in the link below, on a question I asked on SO.
crazyfool_1 said:
Using a remote view to change the text you could use something like this inside your onUpdate:
Code:
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); //set your widget layout
remoteViews.setImageViewResource(R.id.btnToggle, R.drawable.toggle_off); //this changes the image in the imageview btnToggle, remoteViews lets you use setText and a couple of other to manipulate certain widget items
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
This is just a quick example pulled from one of my apps, you could put the database function above it to grab the line of text you want and then set the text in the remote view. The updateAppWidget will update all widgets with this view so if you have multitple different widgets then you'll need to pass the specific widgetId rather then the array.
If you want it to update with a button press on the widget, I would advice you set a pending intent which launches a service, does what you need it to do and then the service update the widget using remote views much like the above code.
Hope that helps
Click to expand...
Click to collapse
Since my last post I have actually done something similar to this, if not the exact same thing. I had to post a question to stack overflow because I was getting a 'process is bad' warning here is the link: http://stackoverflow.com/questions/...base-to-show-on-widget-not-getting-a-response
I chucked the code I've used in the link.
Maybe you could provide some input there? I have been given one answer that I will now look at.
Thanks for helping as well!
Edit: For what it's worth I'm happy to make this project fully opensource once it works for others who want to do the same thing.
I cannot see the link.
EDIT: Thanks.
RED_ said:
I am using the AppWidgetProvider to carry on my database query, within the onUpdate method. I have posted my code in the link below, on a question I asked on SO.
Since my last post I have actually done something similar to this, if not the exact same thing. I had to post a question to stack overflow because I was getting a 'process is bad' warning here is the link: http://stackoverflow.com/questions/...base-to-show-on-widget-not-getting-a-response
I chucked the code I've used in the link.
Maybe you could provide some input there? I have been given one answer that I will now look at.
Thanks for helping as well!
Edit: For what it's worth I'm happy to make this project fully opensource once it works for others who want to do the same thing.
Click to expand...
Click to collapse
Hmm, two things to try is first, uninstall, reboot, install. Sounds obvious but sometimes Eclipse/Android does weird things and a number of Google results suggest this fixes it. Secondly try adding android:label="@string/app_name" to you application tag in the manifest as per here.
If that doesn't work let us know, I think I have an idea of what else it could be but let's see..
crazyfool_1 said:
Hmm, two things to try is first, uninstall, reboot, install. Sounds obvious but sometimes Eclipse/Android does weird things and a number of Google results suggest this fixes it. Secondly try adding android:label="@string/app_name" to you application tag in the manifest as per here.
If that doesn't work let us know, I think I have an idea of what else it could be but let's see..
Click to expand...
Click to collapse
Weird, I'm getting a force close after uninstalling rebooting and installing. Here is the logcat:
Code:
05-01 18:07:02.480: E/AndroidRuntime(2546): FATAL EXCEPTION: main
05-01 18:07:02.480: E/AndroidRuntime(2546): java.lang.RuntimeException: Unable to start receiver com.test.application.TestWidget: java.lang.NullPointerException
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.app.ActivityThread.access$1500(ActivityThread.java:141)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.os.Looper.loop(Looper.java:137)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-01 18:07:02.480: E/AndroidRuntime(2546): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 18:07:02.480: E/AndroidRuntime(2546): at java.lang.reflect.Method.invoke(Method.java:511)
05-01 18:07:02.480: E/AndroidRuntime(2546): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-01 18:07:02.480: E/AndroidRuntime(2546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-01 18:07:02.480: E/AndroidRuntime(2546): at dalvik.system.NativeStart.main(Native Method)
05-01 18:07:02.480: E/AndroidRuntime(2546): Caused by: java.lang.NullPointerException
05-01 18:07:02.480: E/AndroidRuntime(2546): at com.test.application.TestWidget.updateWidgetContent(TestWidget.java:27)
05-01 18:07:02.480: E/AndroidRuntime(2546): at com.test.application.TestWidget.onUpdate(TestWidget.java:22)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:66)
05-01 18:07:02.480: E/AndroidRuntime(2546): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2376)
05-01 18:07:02.480: E/AndroidRuntime(2546): ... 10 more
Edit: My manifest already has android:label="@string/app_name" in the application tag and the receiver tag.
RED_ said:
Weird, I'm getting a force close after uninstalling rebooting and installing. Here is the logcat:
...
Edit: My manifest already has android:label="@string/app_name" in the application tag and the receiver tag.
Click to expand...
Click to collapse
Your dbHelper is null. You have DBHelper dbhelper; but it's never initialized.
crazyfool_1 said:
Your dbHelper is null. You have DBHelper dbhelper; but it's never initialized.
Click to expand...
Click to collapse
You see I thought I fixed that by putting in the last method.
Code:
private static DBHelper getDatabaseHelper(Context context) { }
I might revert back to what I had before. I'll see what I can do.
RED_ said:
You see I thought I fixed that by putting in the last method.
Code:
private static DBHelper getDatabaseHelper(Context context) { }
I might revert back to what I had before. I'll see what I can do.
Click to expand...
Click to collapse
That might work but you haven't called it correctly.. It should be something like the following (untested):
Code:
public static void updateWidgetContent(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
dbhelper = getDatabaseHelper(context);
dbhelper.openDatabase();
String name = "basestring";
Cursor c = dbHelper.getReadableDatabase().rawQuery("SELECT * FROM websites ORDER BY RANDOM()", null);
name = c.getString(c.getColumnIndex("weburl"));
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.main);
remoteView.setTextViewText(R.id.TextView1, name);
dbhelper.close();
appWidgetManager.updateAppWidget(appWidgetIds, remoteView);
}
crazyfool_1 said:
That might work but you haven't called it correctly.. It should be something like the following (untested):
Code:
public static void updateWidgetContent(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
dbhelper = getDatabaseHelper(context);
dbhelper.openDatabase();
String name = "basestring";
Cursor c = dbHelper.getReadableDatabase().rawQuery("SELECT * FROM websites ORDER BY RANDOM()", null);
name = c.getString(c.getColumnIndex("weburl"));
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.main);
remoteView.setTextViewText(R.id.TextView1, name);
dbhelper.close();
appWidgetManager.updateAppWidget(appWidgetIds, remoteView);
}
Click to expand...
Click to collapse
i can't tell if this is progress or not. I have a new error. Cannot open the database.
Code:
05-01 18:33:57.510: E/AndroidRuntime(3440): FATAL EXCEPTION: main
05-01 18:33:57.510: E/AndroidRuntime(3440): java.lang.RuntimeException: Unable to start receiver com.test.application.TestWidget: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.app.ActivityThread.access$1500(ActivityThread.java:141)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.os.Looper.loop(Looper.java:137)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-01 18:33:57.510: E/AndroidRuntime(3440): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 18:33:57.510: E/AndroidRuntime(3440): at java.lang.reflect.Method.invoke(Method.java:511)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-01 18:33:57.510: E/AndroidRuntime(3440): at dalvik.system.NativeStart.main(Native Method)
05-01 18:33:57.510: E/AndroidRuntime(3440): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.text.database.DBHelper.openDatabase(DBHelper.java:62)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.test.application.TestWidget.getDatabaseHelper(TestWidget.java:45)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.test.application.TestWidget.updateWidgetContent(TestWidget.java:26)
05-01 18:33:57.510: E/AndroidRuntime(3440): at com.test.application.TestWidget.onUpdate(TestWidget.java:21)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:66)
05-01 18:33:57.510: E/AndroidRuntime(3440): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2376)
05-01 18:33:57.510: E/AndroidRuntime(3440): ... 10 more
I'm about to clean my project and do an uninstall reboot install.
RED_ said:
i can't tell if this is progress or not. I have a new error. Cannot open the database.
...
I'm about to clean my project and do an uninstall reboot install.
Click to expand...
Click to collapse
A new error is always progress ha ha
It looks like there's a problem with your openDatabase method, best bet would be to set some breakpoints and see where it falls over..
crazyfool_1 said:
A new error is always progress ha ha
It looks like there's a problem with your openDatabase method, best bet would be to set some breakpoints and see where it falls over..
Click to expand...
Click to collapse
I guess so! Thing is a copied the openDatabase method from another project of mine where it works just fine.
It's fairly straightforward in that sense.
Code:
public void openDatabase() throws SQLException {
String myPath = DB_PATH + DB_NAME;
myData = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}
Edit: The crap thing is that there is not a single open source project out there that helps me with this, that I can find anyway. I'm definitely making this open source if I can get it to work.
Here is my DB class that I use. I stripped alot of my functions out but left some to show how I access the DB.
To Call from any activity:
Code:
DBAdapter db = new DBAdapter(this);
db.open();
db.AnyFunctionYouCreate();
db.close();
Code:
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DBAdapter
{
public static final String KEY_ROWID = "_id";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "YourAppName";
private static final int DATABASE_VERSION = 4; //(increased 6/13)increase this when changing db layout
private final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
[user=439709]@override[/user]
public void onCreate(SQLiteDatabase db)
{
db.execSQL("SQL_TO_CREATE_TABLES_HERE");
}
[user=439709]@override[/user]
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion)
{
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS your_table");
onCreate(db);
}
}
public Cursor lastId() {
Cursor yCursor = db.rawQuery("SELECT last_insert_rowid();", null);
if (yCursor != null){
yCursor.moveToFirst();
}
return yCursor;
}
//---opens the database---
public DBAdapter open() throws SQLException
{
db = DBHelper.getWritableDatabase();
return this;
}
//---closes the database---
public void close()
{
DBHelper.close();
}
//---retrieves all responses---
public Cursor getCustomResponse(String number)
{
Cursor cur = db.rawQuery("SELECT " + REP_RESPONSE +
" from " + MY_REPLIES + " where " + REP_AUDIENCE + " = " + number ,new String [] {});
return cur;
/*return db.query(MY_REPLIES, new String[] {
KEY_ROWID,
REP_RESPONSE,
REP_AUDIENCE},
null,
null,
null,
null,
null);*/
}
public Cursor getSetting(String what_table, String what_item)
{
Cursor cur = db.rawQuery("SELECT " + what_item +
" from " + what_table ,new String [] {});
return cur;
}
/**
* Updates Settings Table
*
* [user=955119]@param[/user] long RowId
* [user=955119]@param[/user] String Response
* [user=955119]@param[/user] String LocationStatus
* [user=955119]@param[/user] String LocationPassword
* [user=955119]@param[/user] String TTSStatus
* [user=955119]@param[/user] String VoiceReply
* [user=955119]@param[/user] String AppendMsg
* [user=955119]@param[/user] String NoReplyTimer
* [user=2056652]@return[/user] boolean
*/
public boolean updateSetting(long rowId, String settingResponse,
String locatorStatus, String locatorPass, String tts, String reply, String msgAppend, String timeDelay,
String auto, String silent, String shake)
{
ContentValues initialValues = new ContentValues();
initialValues.put(BUT_RESPONSE, settingResponse);
initialValues.put(BUT_LOCATOR, locatorStatus);
initialValues.put(BUT_LOC_PASS, locatorPass);
initialValues.put(BUT_TTS, tts);
initialValues.put(BUT_VOICE, reply);
initialValues.put(BUT_APPEND, msgAppend);
initialValues.put(BUT_TIME, timeDelay);
initialValues.put(BUT_AUTO_OFF, auto);
initialValues.put(BUT_SILENT, silent);
initialValues.put(BUT_SHAKE, shake);
return db.update(BUTLER_SETTINGS, initialValues,
KEY_ROWID + "=" + rowId, null) > 0;
}
public void emptySmsLog(){
db.execSQL("DELETE FROM sms_log;");
}
}
zalez said:
Here is my DB class that I use. I stripped alot of my functions out but left some to show how I access the DB.
To Call from any activity:
Code:
DBAdapter db = new DBAdapter(this);
db.open();
db.AnyFunctionYouCreate();
db.close();
Code:
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DBAdapter
{
public static final String KEY_ROWID = "_id";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "YourAppName";
private static final int DATABASE_VERSION = 4; //(increased 6/13)increase this when changing db layout
private final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
[user=439709]@override[/user]
public void onCreate(SQLiteDatabase db)
{
db.execSQL("SQL_TO_CREATE_TABLES_HERE");
}
[user=439709]@override[/user]
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion)
{
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS your_table");
onCreate(db);
}
}
public Cursor lastId() {
Cursor yCursor = db.rawQuery("SELECT last_insert_rowid();", null);
if (yCursor != null){
yCursor.moveToFirst();
}
return yCursor;
}
//---opens the database---
public DBAdapter open() throws SQLException
{
db = DBHelper.getWritableDatabase();
return this;
}
//---closes the database---
public void close()
{
DBHelper.close();
}
//---retrieves all responses---
public Cursor getCustomResponse(String number)
{
Cursor cur = db.rawQuery("SELECT " + REP_RESPONSE +
" from " + MY_REPLIES + " where " + REP_AUDIENCE + " = " + number ,new String [] {});
return cur;
/*return db.query(MY_REPLIES, new String[] {
KEY_ROWID,
REP_RESPONSE,
REP_AUDIENCE},
null,
null,
null,
null,
null);*/
}
public Cursor getSetting(String what_table, String what_item)
{
Cursor cur = db.rawQuery("SELECT " + what_item +
" from " + what_table ,new String [] {});
return cur;
}
/**
* Updates Settings Table
*
* [user=955119]@param[/user] long RowId
* [user=955119]@param[/user] String Response
* [user=955119]@param[/user] String LocationStatus
* [user=955119]@param[/user] String LocationPassword
* [user=955119]@param[/user] String TTSStatus
* [user=955119]@param[/user] String VoiceReply
* [user=955119]@param[/user] String AppendMsg
* [user=955119]@param[/user] String NoReplyTimer
* [user=2056652]@return[/user] boolean
*/
public boolean updateSetting(long rowId, String settingResponse,
String locatorStatus, String locatorPass, String tts, String reply, String msgAppend, String timeDelay,
String auto, String silent, String shake)
{
ContentValues initialValues = new ContentValues();
initialValues.put(BUT_RESPONSE, settingResponse);
initialValues.put(BUT_LOCATOR, locatorStatus);
initialValues.put(BUT_LOC_PASS, locatorPass);
initialValues.put(BUT_TTS, tts);
initialValues.put(BUT_VOICE, reply);
initialValues.put(BUT_APPEND, msgAppend);
initialValues.put(BUT_TIME, timeDelay);
initialValues.put(BUT_AUTO_OFF, auto);
initialValues.put(BUT_SILENT, silent);
initialValues.put(BUT_SHAKE, shake);
return db.update(BUTLER_SETTINGS, initialValues,
KEY_ROWID + "=" + rowId, null) > 0;
}
public void emptySmsLog(){
db.execSQL("DELETE FROM sms_log;");
}
}
Click to expand...
Click to collapse
Thanks, just got around to finding some time. Do you think I need to implement all of that for what I need? Obviously changing the actual calls to the database. Also DATABASE_NAME = "YourAppName" should be where your database name goes not your app name right? Or have I got that wrong?
You would be the only one to decide if you need all of that class. I reuse it in many apps for database purposes. That class is what I use with my widget provider. DATABASE_NAME is for your app name. Because when your app creates a database in the system/data area, it is stored by appname.
RED_ said:
Thanks, just got around to finding some time. Do you think I need to implement all of that for what I need? Obviously changing the actual calls to the database. Also DATABASE_NAME = "YourAppName" should be where your database name goes not your app name right? Or have I got that wrong?
Click to expand...
Click to collapse
zalez said:
You would be the only one to decide if you need all of that class. I reuse it in many apps for database purposes. That class is what I use with my widget provider. DATABASE_NAME is for your app name. Because when your app creates a database in the system/data area, it is stored by appname.
Click to expand...
Click to collapse
Ok, well it's telling me it can't find a table called "websites" in my database. I know for sure there it's there. This is annoying.
Here's the code I used from yours in my DBAdapter: http://pastebin.com/v0CWcr3t
and how I called it in my widget provider: http://pastebin.com/LDmvASdK
EDIT: I think the error is because I have my database in my assets folder and we are not copying it to the data/data folder.
I can link to System settings>Location access with Settings.ACTION_LOCATION_SOURCE_SETTINGS
Fine...but I want to link to System settings>Accounts(Google)>Location settings (this screen is called Google apps location settings)
Does someone know how to do this? Or at least how to get close to there?
Another issue I'm struggling with is how to link to PlayStore>Settings>Ads screen. Has someone an idea?
In the App Ops screen on Android 4.3, find the activity in the settings that you like to open, and launch it the usual way via intent. If you don't have 4.3 yet, you'd have to look at the Android source code and find it there
SimplicityApks said:
In the App Ops screen on Android 4.3, find the activity in the settings that you like to open, and launch it the usual way via intent. If you don't have 4.3 yet, you'd have to look at the Android source code and find it there
Click to expand...
Click to collapse
Thank you for your reply. I can try 4.3 soon. I planned to be compatible with 4.1+. If it is only possible to support 4.3+, that is at least something. Can you tell me how I can code it under 4.3+?`
I would list all activities on my device using the solution provided here.
Then choose the right one from the settings app.
alterechtschreibung said:
Thank you for your reply. I can try 4.3 soon. I planned to be compatible with 4.1+. If it is only possible to support 4.3+, that is at least something. Can you tell me how I can code it under 4.3+?`
Click to expand...
Click to collapse
OK sry, my fault. You don't need 4.3, just create a shortcut in Nova Launcher with activities - >settings and search the right activity. Why I thought 4.3 was needed is only because that was where I created a shortcut on the Homescreen to an activity the last time...
The code itself is clear:
Code:
Intent I = new Intent( "com.google.android.location.settings.GoogleLocationSettingsActivity" );
startActivity(i);
Edit got it!
You probably mean this screen:
"com.google.android.location.settings.GoogleLocationSettingsActivity"
SimplicityApks said:
OK sry, my fault. You don't need 4.3, just create a shortcut in Nova Launcher with activities - >settings and search the right activity. Why I thought 4.3 was needed is only because that was where I created a shortcut on the Homescreen to an activity the last time...
The code itself is clear:
Code:
Intent I = new Intent( "com.google.android.location.settings.GoogleLocationSettingsActivity" );
startActivity(i);
Edit got it!
You probably mean this screen:
"com.google.android.location.settings.GoogleLocationSettingsActivity"
Click to expand...
Click to collapse
Thank you. Unfortunately app crashes when calling it:
I/ActivityManager( 1473): START {act=com.google.android.location.settings.GoogleLocationSettingsActivity u=0} from pid 3501
D/AndroidRuntime( 3501): Shutting down VM
W/dalvikvm( 3501): threadid=1: thread exiting with uncaught exception (group=0x40a9f300)
E/AndroidRuntime( 3501): FATAL EXCEPTION: main
E/AndroidRuntime( 3501): java.lang.IllegalStateException: Could not execute method of the activity
alterechtschreibung said:
Thank you. Unfortunately app crashes when calling it:
I/ActivityManager( 1473): START {act=com.google.android.location.settings.GoogleLocationSettingsActivity u=0} from pid 3501
D/AndroidRuntime( 3501): Shutting down VM
W/dalvikvm( 3501): threadid=1: thread exiting with uncaught exception (group=0x40a9f300)
E/AndroidRuntime( 3501): FATAL EXCEPTION: main
E/AndroidRuntime( 3501): java.lang.IllegalStateException: Could not execute method of the activity
Click to expand...
Click to collapse
I also modified the code with no luck:
public void showClick_google_apps_location_settings(View view) {
Intent intent = showGoogleAppsLocationSettings();
startActivity(intent);
}
public static Intent showGoogleAppsLocationSettings() {
Intent intent = new Intent("com.google.android.location.settings.GoogleLocationSettingsActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
return intent;
}
Strange... Normally this should work... Maybe try to set the method not static but that shouldn't do anything actually.
SimplicityApks said:
Strange... Normally this should work... Maybe try to set the method not static but that shouldn't do anything actually.
Click to expand...
Click to collapse
Do I need certain permissions for com.google.android.location.settings.GoogleLocationSettingsActivity?
Usually not... You're testing on a real device, not an emulator aren't you?
SimplicityApks said:
Usually not... You're testing on a real device, not an emulator aren't you?
Click to expand...
Click to collapse
I'm on a real device with Android 4.1.x
I tried Nova Launcher. There is this entry:
settings.GoogleLocationSettings$Activity
Google apps location settings
This shortcut in Nova works. In my app it causes the crash.
If there is further code required, just tell me.
I hope probably not.That's it....
Sent from my Xperia U using xda app-developers app
Karchikumar said:
I hope probably not.That's it....
Sent from my Xperia U using xda app-developers app
Click to expand...
Click to collapse
What's wrong with testing on a real device? Finally the app must run on real devices and not in an emulator.
alterechtschreibung said:
What's wrong with testing on a real device? Finally the app must run on real devices and not in an emulator.
Click to expand...
Click to collapse
Nothing, testing on the emulator could crash since the Goggle settings may not be installed.
Really interesting and strange that it crashes, the only thing you can do now is to try other shortcuts and see if they work and it is just the Google location setting.
SimplicityApks said:
Nothing, testing on the emulator could crash since the Goggle settings may not be installed.
Really interesting and strange that it crashes, the only thing you can do now is to try other shortcuts and see if they work and it is just the Google location setting.
Click to expand...
Click to collapse
That works:
public void showClick_backup_restore_settings(View view) {
Intent intent = showBackupRestoreSettings();
startActivity(intent);
}
public static Intent showBackupRestoreSettings() {
Intent intent = new Intent(Settings.ACTION_PRIVACY_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
return intent;
}
and that works too:
public void showClick_google_apps_location_settings(View view) {
PackageManager packageManager = getPackageManager();
String packageName = ("com.dozingcatsoftware.asciicam");
try {
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if(null != intent) {
startActivity(intent);
}
}
catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
-----
while this doesn't work:
public void showClick_google_apps_location_settings(View view) {
PackageManager packageManager = getPackageManager();
String packageName = ("com.google.android.location.settings.GoogleLocationSettingsActivity");
try {
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if(null != intent) {
startActivity(intent);
}
}
catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
and this doesn't work either:
public void showClick_google_apps_location_settings(View view) {
Intent intent = showGoogleAppsLocationSettings();
startActivity(intent);
}
public static Intent showGoogleAppsLocationSettings() {
Intent intent = new Intent("com.google.android.location.settings.GoogleLocationSettingsActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
return intent;
}
Right before i start, i have looked absolutely everywhere for the answer but there's only so much that people talk about so this is my last hope because I've tried and tried but simply can't do it!
Now i understand that to some this may be a very very easy thing to do and although i have learnt a hell of a lot since i started developing, I'm just not a pro (Just yet)
So basically ever since i started my music player, I've had one big problem and that's trying to list music albums and the songs, now, I have code that does work but it simply doesn't go with my apps data source so I'm trying to the code that i done but the code that I done doesn't show the list of songs, becauser it crashes
Here's the code so far:
Code:
public class AlbumsList extends ListActivity{
public ArrayList<HashMap<String,String>> albumsList = new ArrayList<HashMap<String, String>>();
ListView musiclist;
int songAlbum;
int count;
int songPath;
private Cursor cursor;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.albums);
ArrayList<HashMap<String, String>> albumListData = new ArrayList<HashMap<String, String>>();
final AlbumsList plm = new AlbumsList();
// get all songs from sdcard
this.albumsList = plm.getPlayList(this, count);
// looping through playlist
for (int i = 0; i < albumsList.size(); i++) {
// creating new HashMap
HashMap<String, String> album = albumsList.get(i);
// adding HashList to ArrayList
albumListData.add(album);
}
// Adding menuItems to ListView
ListAdapter adapter = new SimpleAdapter(this, albumListData,
android.R.layout.simple_list_item_1, new String[] { "songAlbum", "songTitle", "orderBy", "songPath", "where", "whereVal" }, new int[] {
android.R.id.text1});
setListAdapter(adapter);
}
public ArrayList<HashMap<String, String>> getPlayList(Context c, int position) {
final String[] columns = { BaseColumns._ID,
AlbumColumns.ALBUM };
final Cursor mCursor = c.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
columns, null, null, null);
String songAlbum = "";
if (mCursor.moveToFirst()) {
do {
mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
songAlbum = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));
HashMap<String, String> album = new HashMap<String, String>();
album.put("songAlbum", songAlbum);
albumsList.add(album);
} while (mCursor.moveToNext());
}
return albumsList;
}
@Override
protected void onListItemClick(ListView lv, View v, int position, long id) {
if(cursor.moveToPosition(position)){
cursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaColumns.TITLE, MediaColumns.DATA, AudioColumns.ALBUM, BaseColumns._ID }, null, null,
"LOWER(" + MediaColumns.TITLE + ") ASC");
String where = AudioColumns.ALBUM
+ "=?";
String whereVal = cursor.getString(cursor.getColumnIndex(AlbumColumns.ALBUM));
String orderBy = MediaColumns.TITLE;
String songTitle = MediaColumns.TITLE;
String songPath = cursor.getString(cursor.getColumnIndexOrThrow(MediaColumns.DATA));
HashMap<String, String> album = new HashMap<String, String>();
album.put("songTitle", songTitle);
album.put("where", where);
album.put("whereVal", whereVal);
album.put("orderBy", orderBy);
album.put("songPath", songPath);
albumsList.add(album);
}else{
}
}
}
That Code successfully gets all the albums but it won't get the songs from the selected album
Here's the LogCat:
Code:
03-18 18:42:21.579: E/AndroidRuntime(10214): at dalvik.system.NativeStart.main(Native Method)
03-18 18:46:48.223: E/SpannableStringBuilder(12325): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-18 18:46:48.223: E/SpannableStringBuilder(12325): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-18 18:46:48.894: E/AndroidRuntime(12325): FATAL EXCEPTION: main
03-18 18:46:48.894: E/AndroidRuntime(12325): java.lang.NullPointerException
03-18 18:46:48.894: E/AndroidRuntime(12325): at com.simplistic.simplisticmusicfree.AlbumsList.onListItemClick(AlbumsList.java:93)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.widget.AdapterView.performItemClick(AdapterView.java:301)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.widget.AbsListView.performItemClick(AbsListView.java:1519)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3291)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.widget.AbsListView$1.run(AbsListView.java:4340)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.os.Handler.handleCallback(Handler.java:725)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.os.Handler.dispatchMessage(Handler.java:92)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.os.Looper.loop(Looper.java:137)
03-18 18:46:48.894: E/AndroidRuntime(12325): at android.app.ActivityThread.main(ActivityThread.java:5328)
03-18 18:46:48.894: E/AndroidRuntime(12325): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 18:46:48.894: E/AndroidRuntime(12325): at java.lang.reflect.Method.invoke(Method.java:511)
03-18 18:46:48.894: E/AndroidRuntime(12325): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
03-18 18:46:48.894: E/AndroidRuntime(12325): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
03-18 18:46:48.894: E/AndroidRuntime(12325): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
03-18 18:46:48.894: E/AndroidRuntime(12325): at dalvik.system.NativeStart.main(Native Method)
Also just in case your wondering, this is music player in question: https://play.google.com/store/apps/details?id=com.simplistic.simplisticmusicfree
So yeah please for the love of god, help!!!
Updated the Question!
AmatuerAppDeveloper said:
Updated the Question!
Click to expand...
Click to collapse
Sorry but there seems to be a few simple problems there, and the error tells you what it is. I would suspect that the tutorials you have followed have not done a great job, or that you skipped some quite basic things... maybe learn some Java 101 and android basics. BTW I don't mean to sound condescending, I'm actually an authorised Autodesk instructor and developer and artist/trainer so it's maybe the way I say things, it's often for the total benefit of the individual I'm talking to, and quite blunt sometimes.
Your problem is clear and outlined in that error,
Code:
03-18 18:46:48.894: E/AndroidRuntime(12325): java.lang.NullPointerException
03-18 18:46:48.894: E/AndroidRuntime(12325): at com.simplistic.simplisticmusicfree.AlbumsList.onListItemClick(AlbumsList.java:93)
so on line 93, you are asking an "Object" that is actually "NULL" to execute or reference data or method, I would guess that it is as simple as the
Code:
private Cursor cursor;
You never assign it anything, you just create a null reference there. But then you ask it (Being null at this point) to ".moveToPosition()"
BTW: Still not fully awake and only glimpsed at your post
deanwray said:
Sorry but there seems to be a few simple problems there, and the error tells you what it is. I would suspect that the tutorials you have followed have not done a great job, or that you skipped some quite basic things... maybe learn some Java 101 and android basics. BTW I don't mean to sound condescending, I'm actually an authorised Autodesk instructor and developer and artist/trainer so it's maybe the way I say things, it's often for the total benefit of the individual I'm talking to, and quite blunt sometimes.
Your problem is clear and outlined in that error,
Code:
03-18 18:46:48.894: E/AndroidRuntime(12325): java.lang.NullPointerException
03-18 18:46:48.894: E/AndroidRuntime(12325): at com.simplistic.simplisticmusicfree.AlbumsList.onListItemClick(AlbumsList.java:93)
so on line 93, you are asking an "Object" that is actually "NULL" to execute or reference data or method, I would guess that it is as simple as the
Code:
private Cursor cursor;
You never assign it anything, you just create a null reference there. But then you ask it (Being null at this point) to ".moveToPosition()"
BTW: Still not fully awake and only glimpsed at your post
Click to expand...
Click to collapse
Thanks for the reply, I'll have to re look the code and see what I can do, also I'd like to note that I downloaded your beta app and I have to say it certainly looks promising, so im looking forward to official release
AmatuerAppDeveloper said:
Thanks for the reply, I'll have to re look the code and see what I can do, also I'd like to note that I downloaded your beta app and I have to say it certainly looks promising, so im looking forward to official release
Click to expand...
Click to collapse
Thanks for the download Yeah well my 1st app, and still a number of months away from what I would call "releasable".. Need to get all the user in app theming ability in there
The BT-2000 is out as well, and I have had the pleasure of using it for two weeks. It's an interesting device with a stereoscopic camera on the front. Any thoughts of what we could do with a cool feature like that? And are there people out here that see advantages over the BT-200?
My thoughts:
Pros:
Great battery life
Great see through screen
Can handle a bump
Interesting features like IMU
Cons:
Too big, too bulky
5 megapixel camera lacks autofocus
Wired controller isn't very cool
More info:
Epson SDK and developers info
Article about the BT-2000
Bt-2000 pro
Pros:
- Android tablet version
Cons:
- no Moverio app store
- no mouse
- no installed app (for example : no glass mirror)
- no control over display and camera setting
BT2000pro said:
Pros:
- Android tablet version
Cons:
- no Moverio app store
- no mouse
- no installed app (for example : no glass mirror)
- no control over display and camera setting
Click to expand...
Click to collapse
Not totally true, you can use the camera settings with the SDK provided by Epson. Mouse works with an OTG cable.
Hi, anyone developped program for BT-2000 ..?
I have some issues with the EPSON library.
I don't understand why I'm not abble to call some methods form Camera class like setEpsonCameraMode();
If you have ideas ..?
Thanks
Franck
Franck_Cordu said:
Hi, anyone developped program for BT-2000 ..?
I have some issues with the EPSON library.
I don't understand why I'm not abble to call some methods form Camera class like setEpsonCameraMode();
If you have ideas ..?
Thanks
Franck
Click to expand...
Click to collapse
Dear Franck,
This is because Android Studio doesn't recognize these methods as being correct, so it will mark then as faulty or non-existing. You can run the app on the Moverio BT-2000 and you will see that it will work. Don't forget to set the camera fps and preview size to the correct supported values otherwise the app will crash.
Good luck!
Thanks for your answer.
But, I'm sorry, how can you dev apps witch don't compile in Android Studio and install it on the BT2000..?
Moreover, I have contact EPSON support and they gave me a solution to make this methods recognizable by android studio I can give the solution here if someone is interested.
So there is a compatibility problem with packages names.
To finish, I finally succeed to change camera mode, and as you said you have to well configure parameters if not there is a crash. By any chance have you the good parameters to set 5m pixel mode and depth only mode ..?
Thanks a lot for your help,
Best regards,
Franck_Cordu said:
Thanks for your answer.
But, I'm sorry, how can you dev apps witch don't compile in Android Studio and install it on the BT2000..?
Moreover, I have contact EPSON support and they gave me a solution to make this methods recognizable by android studio I can give the solution here if someone is interested.
So there is a compatibility problem with packages names.
To finish, I finally succeed to change camera mode, and as you said you have to well configure parameters if not there is a crash. By any chance have you the good parameters to set 5m pixel mode and depth only mode ..?
Thanks a lot for your help,
Best regards,
Click to expand...
Click to collapse
You need to get the manual to see which FPS ranges are supported by the set camera modes. These are documented in the manual that is on the Epson website. Below the code you need:
Camera.Parameters params = mCamera.getParameters();
params.getEpsonCameraMode();
//Get the supported camera modes (one of them will be 5MP and one will be depth, check debugger for these values)
List<String> supported = params.getSupportedEpsonCameraModes();
//set the desired camera mode
params.setEpsonCameraMode(supported.get(2));
//set the supported FPS range
params.setPreviewFpsRange(7500, 7500);
//Set desired preview size and picture size
params.setPreviewSize(640, 480);
params.setPictureSize(640, 480);
Thanks, effectively that are perfect parameters for single-vga mode but have you the rights ones to 5M mode and depth mode.
When I follow the dev_guide page 62 I have a crash with 5m mode when I invoke setParameters(), with these parameters :
params.setEpsonCameraMode(Supported.get(5));
params.setPreviewSize(2596, 1948);
params.setPreviewFpsRange(7500, 7500);
params.setPictureSize(2596, 1948);
With the depth mode I use theses parameters :
params.setEpsonCameraMode(Supported.get(6));
params.setPreviewSize(640, 480);
params.setPreviewFpsRange(7500, 7500);
params.setPictureSize(640, 480);
l_pCamera.startDepthStreaming(); // I don't forget to start depth mode
And the preview is lunch but the image stay transparent, nothing happen.
If you have any solution.
Thanks a lot.
Franck_Cordu said:
Thanks, effectively that are perfect parameters for single-vga mode but have you the rights ones to 5M mode and depth mode.
When I follow the dev_guide page 62 I have a crash with 5m mode when I invoke setParameters(), with these parameters :
params.setEpsonCameraMode(Supported.get(5));
params.setPreviewSize(2596, 1948);
params.setPreviewFpsRange(7500, 7500);
params.setPictureSize(2596, 1948);
With the depth mode I use theses parameters :
params.setEpsonCameraMode(Supported.get(6));
params.setPreviewSize(640, 480);
params.setPreviewFpsRange(7500, 7500);
params.setPictureSize(640, 480);
l_pCamera.startDepthStreaming(); // I don't forget to start depth mode
And the preview is lunch but the image stay transparent, nothing happen.
If you have any solution.
Thanks a lot.
Click to expand...
Click to collapse
PreviewSize is too big with 5MP, can maximum be 1920x1080 with 7500fps. Try:
params.setEpsonCameraMode(Supported.get(5));
params.setPreviewSize(1920, 1080);
params.setPreviewFpsRange(7500, 7500);
params.setPictureSize(2596, 1948);
Don't forget to call Camera.setParameters(params);
Can't help with the depth sensing as I never used it.
Nice thanks a lot, I don't know why, but I think I done exactly the same yesterday and it didn't work, but today it work perfectly.
Thanks a lot, now I'm looking for someone who is able to set Depth mode..
Again, thanks for your time !
Franck_Cordu said:
Nice thanks a lot, I don't know why, but I think I done exactly the same yesterday and it didn't work, but today it work perfectly.
Thanks a lot, now I'm looking for someone who is able to set Depth mode..
Again, thanks for your time !
Click to expand...
Click to collapse
Your welcome, don't forget to hit the thanks button!
Load the epson Camera class version in Android Studio
Franck_Cordu said:
Thanks for your answer.
But, I'm sorry, how can you dev apps witch don't compile in Android Studio and install it on the BT2000..?
Moreover, I have contact EPSON support and they gave me a solution to make this methods recognizable by android studio I can give the solution here if someone is interested.
So there is a compatibility problem with packages names.
(...)
Click to expand...
Click to collapse
Hi Franck,
I run into the same problem. The Camera class from the Epson library has the same package name as the android Camera class: android.hardware.Camera . So Android Studio finds the android version instead of the Epson one. Can you show the solution please?
Thanks!
I'd be really interested in knowing how you (Franck_Cordu) have resolved the compilation issues with the BT-2000 API. I'm running into the same problems as you are and am desperate for a working solution!
Hello,
First a quick answer for the compilation problem:
--> have a look at the manual (https://tech.moverio.epson.com/en/bt-2000/tools.html), putting and referring correctly the H725Ctrl.jar is a key.
--> they even propose a kind of partial solution in order to have completion. It has to be redone every time you compile/recompile your program though. (Changing the order in the app.iml file)
On my side, I have a very painful problem: (version R1.3 here)
I have carefully followed their Sample Code (Ch. 6.10) but I am unable to open the camera. The system always fails at the camera.open() command in the function below, the output error is shown below the function.
Do any of you understand what may be the problem ? Or anyone could submit a working source code that I could try ....
Code:
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated");
try {
camera = android.hardware.Camera.open();
camera.setPreviewDisplay(holder);
} catch (RuntimeException e) {
Log.d("SR-DEBUG", "There has been a problem opening the camera");
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
camera.addCallbackBuffer(mPreviewBuf);
camera.setPreviewCallbackWithBuffer(mPreviewCB);
}
Returned Error:
Code:
09-22 14:28:28.437 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 D/com.example.simonruffieux.test_cameradisplay_bt2000.MainActivity: surfaceCreated
09-22 14:28:28.437 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 V/Camera: connect
09-22 14:28:28.445 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 D/SR-DEBUG: There has been a problem opening the camera
09-22 14:28:28.445 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: java.lang.RuntimeException: Fail to connect to camera service
09-22 14:28:28.445 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.hardware.Camera.native_setup(Native Method)
09-22 14:28:28.445 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.hardware.Camera.<init>(Camera.java:317)
09-22 14:28:28.445 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.hardware.Camera.open(Camera.java:294)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at com.example.simonruffieux.test_cameradisplay_bt2000.MainActivity$2.surfaceCreated(MainActivity.java:70)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.SurfaceView.updateWindow(SurfaceView.java:543)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.SurfaceView.access$000(SurfaceView.java:82)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:170)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
09-22 14:28:28.453 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.os.Looper.loop(Looper.java:137)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at android.app.ActivityThread.main(ActivityThread.java:4424)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at java.lang.reflect.Method.invoke(Method.java:511)
09-22 14:28:28.460 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-22 14:28:28.468 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-22 14:28:28.468 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/System.err: at dalvik.system.NativeStart.main(Native Method)
09-22 14:28:28.468 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 D/AndroidRuntime: Shutting down VM
09-22 14:28:28.468 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40a891f8)
09-22 14:28:28.484 11461-11461/com.example.simonruffieux.test_cameradisplay_bt2000 E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.simonruffieux.test_cameradisplay_bt2000.MainActivity$2.surfaceCreated(MainActivity.java:79)
at android.view.SurfaceView.updateWindow(SurfaceView.java:543)
at android.view.SurfaceView.access$000(SurfaceView.java:82)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:170)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
I am using the following <project>/app/build.gradle:
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.simonruffieux.test_cameradisplay_bt2000"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile files('libs/H725Ctrl.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
}
The following <project>/build.gradle
Code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:D:/Devel/Android/test_CameraDisplay_BT2000/app/libs/H725Ctrl.jar')
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And finally, the whole MainActivity.java class:
Code:
package com.example.simonruffieux.test_cameradisplay_bt2000;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.app.Activity;
import android.util.Log;
import android.hardware.Camera;
import android.view.WindowManager;
import android.os.Bundle;
import java.util.List;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
private String TAG = this.getClass().getName();
private Camera camera = null;
private SurfaceHolder mHolder = null;
private byte[] mPreviewData = new byte[1920 * 1080 * 3 / 2];
private byte[] mPreviewBuf = new byte[1920 * 1080 * 3 / 2];
private Object lockObject = new Object();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//SR Full Screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(0x80000000);
//SR Tests
//camera = Camera.open();
//Camera.Parameters params = camera.getParameters();
//List<String> supportedMode = params.getSupportedEpsonCameraMode(); not accepted, says it does not know this method ...
//SR set camera callback to SurfaceView
SurfaceView cameraPreview = (SurfaceView) findViewById(R.id.preview);
mHolder = cameraPreview.getHolder();
mHolder.addCallback(previewCallback);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
private Camera.PreviewCallback mPreviewCB = new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
Log.d(TAG, "Save preview image");
synchronized (lockObject) {
mPreviewData = data;
}
camera.addCallbackBuffer(mPreviewBuf);
}
};
private SurfaceHolder.Callback previewCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "surfaceDestroyed");
camera.stopPreview();
camera.release();
camera = null;
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated");
try {
camera = android.hardware.Camera.open();
camera.setPreviewDisplay(holder);
} catch (RuntimeException e) {
Log.d("SR-DEBUG", "There has been a problem opening the camera");
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
camera.addCallbackBuffer(mPreviewBuf);
camera.setPreviewCallbackWithBuffer(mPreviewCB);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
camera.stopPreview();
Camera.Parameters params = camera.getParameters();
/* Set camera mode to single-through-5m mode*/
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MODE_SINGLE_THROUGH_5M);
/* Set preview resolution to 1080p */
params.setPreviewSize(1920, 1080);
/* Set frame rate to 7.5fps */
params.setPreviewFpsRange(7500, 7500);
/* Reflect parameter change to camera device */
camera.setParameters(params);
camera.addCallbackBuffer(mPreviewData);
camera.setPreviewCallbackWithBuffer(mPreviewCB);
try {
camera.startPreview();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
};
}