GetWindowRect() fails, but IsWindow() is not
I am trying to get the size of an external window:
POINT point;
point.x = 100;
point.y = 100;
HWND hwnd = WindowFromPoint(point);
LPRECT pRect = {0};
bool ret1 = IsWindow(hwnd);
bool ret = GetWindowRect(hwnd, pRect);
The return value of IsWindow is true, but GetWindowRect fails with the
following error:
1400: Invalid window handle
What can be wrong?
Buttler
Sunday, 1 September 2013
NoMethodError in Posts#new
NoMethodError in Posts#new
im doing the getting started with Rails tutorial on:
http://guides.rubyonrails.org/getting_started.html when i run the local
server from shell i got this:
NoMethodError in Posts#new /_form.html.erb where line #1 raised: undefined
method `model_name' for NilClass:Class
That is the extracted source(arround line #1):
1: <%= form_for @post do |f| %>
2: <% if @post.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@post.errors.count, "error") %> prohibited
I just started on Ruby on rails and i can' figure it out what is
happening. Some help must be apreciated. Thanks.
im doing the getting started with Rails tutorial on:
http://guides.rubyonrails.org/getting_started.html when i run the local
server from shell i got this:
NoMethodError in Posts#new /_form.html.erb where line #1 raised: undefined
method `model_name' for NilClass:Class
That is the extracted source(arround line #1):
1: <%= form_for @post do |f| %>
2: <% if @post.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@post.errors.count, "error") %> prohibited
I just started on Ruby on rails and i can' figure it out what is
happening. Some help must be apreciated. Thanks.
Code is not playing any audio
Code is not playing any audio
Hi I have been trying to work this code out for a while now, but it gives
an error to the logcat as follows:
09-01 13:14:28.799: E/AwesomePlayer(123): reset+
09-01 13:14:28.799: E/AwesomePlayer(123): reset at1
09-01 13:14:28.799: E/AwesomePlayer(123): reset-
09-01 13:14:28.799: E/AwesomePlayer(123): reset at1
09-01 13:14:28.799: E/MediaPlayer(3092): error (1, -2147483648)
STACKTRACE
09-01 13:31:33.749: E/MediaPlayer(3458): error (1, -2147483648)
09-01 13:31:33.759: E/~~IOException~~(3458): java.io.IOException: Prepare
failed.: status=0x1
09-01 13:31:33.789: E/->>(3458): ~~stacktrace~~
09-01 13:31:33.789: E/->>(3458): java.io.IOException: Prepare failed.:
status=0x1
09-01 13:31:33.789: E/->>(3458): at
android.media.MediaPlayer.prepare(Native Method)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist.playSong(Playlist.java:110)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist.access$0(Playlist.java:104)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist$1.onItemClick(Playlist.java:75)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AdapterView.performItemClick(AdapterView.java:292)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView.performItemClick(AbsListView.java:1070)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView$PerformClick.run(AbsListView.java:2527)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView$1.run(AbsListView.java:3188)
09-01 13:31:33.789: E/->>(3458): at
android.os.Handler.handleCallback(Handler.java:605)
09-01 13:31:33.789: E/->>(3458): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-01 13:31:33.789: E/->>(3458): at
android.os.Looper.loop(Looper.java:137)
09-01 13:31:33.789: E/->>(3458): at
android.app.ActivityThread.main(ActivityThread.java:4424)
09-01 13:31:33.789: E/->>(3458): at
java.lang.reflect.Method.invokeNative(Native Method)
09-01 13:31:33.789: E/->>(3458): at
java.lang.reflect.Method.invoke(Method.java:511)
09-01 13:31:33.789: E/->>(3458): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
09-01 13:31:33.789: E/->>(3458): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
09-01 13:31:33.789: E/->>(3458): at
dalvik.system.NativeStart.main(Native Method)
This is my class containing the code:
public class Playlist extends Activity
{
ListView lstview;
ArrayList<String> Songslist;
ArrayList<String> Path;
ArrayAdapter<String> Adapteraa;
Cursor cursor;
Uri allsongsuri;
String selection;
Thread tsearchsongs;
MediaPlayer mMediaPlayer=new MediaPlayer();
Toast t1;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
//PREPARATIONS FOR ACTIVITY
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist);
// Show the Up button in the action bar.
setupActionBar();
//INITIALIZATIONS
lstview=(ListView)findViewById(R.string.playlistHolder);
Songslist=new ArrayList<String>();
Path=new ArrayList<String>();
Adapteraa=new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Songslist);
lstview.setAdapter(Adapteraa);
String[] STAR = { "*" };
allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
cursor=managedQuery(allsongsuri, STAR, selection, null, null);
t1=new Toast(getApplicationContext());
GETSONGS();
//LISTENERS
lstview.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int
arg2,long arg3)
{
// TODO Auto-generated method stub
int songclicked=arg2;
String songpath=Path.get(songclicked).toString();
try
{
playSong(songpath);
}
catch (IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
private void playSong(String path) throws IllegalArgumentException,
IllegalStateException, IOException
{
String extStorageDirectory =
Environment.getExternalStorageDirectory().toString();
path = extStorageDirectory + File.separator + path;
mMediaPlayer.reset();
mMediaPlayer.setDataSource(path);
mMediaPlayer.prepare();
mMediaPlayer.start();
}
Do I need to start a service for this? And do I need to declare any
permissions for the playing of sound as it is for storage?
Hi I have been trying to work this code out for a while now, but it gives
an error to the logcat as follows:
09-01 13:14:28.799: E/AwesomePlayer(123): reset+
09-01 13:14:28.799: E/AwesomePlayer(123): reset at1
09-01 13:14:28.799: E/AwesomePlayer(123): reset-
09-01 13:14:28.799: E/AwesomePlayer(123): reset at1
09-01 13:14:28.799: E/MediaPlayer(3092): error (1, -2147483648)
STACKTRACE
09-01 13:31:33.749: E/MediaPlayer(3458): error (1, -2147483648)
09-01 13:31:33.759: E/~~IOException~~(3458): java.io.IOException: Prepare
failed.: status=0x1
09-01 13:31:33.789: E/->>(3458): ~~stacktrace~~
09-01 13:31:33.789: E/->>(3458): java.io.IOException: Prepare failed.:
status=0x1
09-01 13:31:33.789: E/->>(3458): at
android.media.MediaPlayer.prepare(Native Method)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist.playSong(Playlist.java:110)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist.access$0(Playlist.java:104)
09-01 13:31:33.789: E/->>(3458): at
com.example.boombastic.Playlist$1.onItemClick(Playlist.java:75)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AdapterView.performItemClick(AdapterView.java:292)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView.performItemClick(AbsListView.java:1070)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView$PerformClick.run(AbsListView.java:2527)
09-01 13:31:33.789: E/->>(3458): at
android.widget.AbsListView$1.run(AbsListView.java:3188)
09-01 13:31:33.789: E/->>(3458): at
android.os.Handler.handleCallback(Handler.java:605)
09-01 13:31:33.789: E/->>(3458): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-01 13:31:33.789: E/->>(3458): at
android.os.Looper.loop(Looper.java:137)
09-01 13:31:33.789: E/->>(3458): at
android.app.ActivityThread.main(ActivityThread.java:4424)
09-01 13:31:33.789: E/->>(3458): at
java.lang.reflect.Method.invokeNative(Native Method)
09-01 13:31:33.789: E/->>(3458): at
java.lang.reflect.Method.invoke(Method.java:511)
09-01 13:31:33.789: E/->>(3458): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
09-01 13:31:33.789: E/->>(3458): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
09-01 13:31:33.789: E/->>(3458): at
dalvik.system.NativeStart.main(Native Method)
This is my class containing the code:
public class Playlist extends Activity
{
ListView lstview;
ArrayList<String> Songslist;
ArrayList<String> Path;
ArrayAdapter<String> Adapteraa;
Cursor cursor;
Uri allsongsuri;
String selection;
Thread tsearchsongs;
MediaPlayer mMediaPlayer=new MediaPlayer();
Toast t1;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
//PREPARATIONS FOR ACTIVITY
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist);
// Show the Up button in the action bar.
setupActionBar();
//INITIALIZATIONS
lstview=(ListView)findViewById(R.string.playlistHolder);
Songslist=new ArrayList<String>();
Path=new ArrayList<String>();
Adapteraa=new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Songslist);
lstview.setAdapter(Adapteraa);
String[] STAR = { "*" };
allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
cursor=managedQuery(allsongsuri, STAR, selection, null, null);
t1=new Toast(getApplicationContext());
GETSONGS();
//LISTENERS
lstview.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int
arg2,long arg3)
{
// TODO Auto-generated method stub
int songclicked=arg2;
String songpath=Path.get(songclicked).toString();
try
{
playSong(songpath);
}
catch (IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
private void playSong(String path) throws IllegalArgumentException,
IllegalStateException, IOException
{
String extStorageDirectory =
Environment.getExternalStorageDirectory().toString();
path = extStorageDirectory + File.separator + path;
mMediaPlayer.reset();
mMediaPlayer.setDataSource(path);
mMediaPlayer.prepare();
mMediaPlayer.start();
}
Do I need to start a service for this? And do I need to declare any
permissions for the playing of sound as it is for storage?
Saturday, 31 August 2013
Using ConcurrentHashMap efficiently?
Using ConcurrentHashMap efficiently?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
Jenkins: How to modify PATH environment variable for build steps?
Jenkins: How to modify PATH environment variable for build steps?
I'm trying to follow the instructions here to prepend a directory to path
for my build steps. However, the instructions reference the deprecated
SetEnv plugin. I tried playing with the new EnvInject plugin, setting
PATH=mydir:$PATH in Script Content field of the "Inject Build Environments
to the build process" section. However, the path is not updated when my
build step shell scripts execute.
I'm trying to follow the instructions here to prepend a directory to path
for my build steps. However, the instructions reference the deprecated
SetEnv plugin. I tried playing with the new EnvInject plugin, setting
PATH=mydir:$PATH in Script Content field of the "Inject Build Environments
to the build process" section. However, the path is not updated when my
build step shell scripts execute.
Difference between Kivy and Java for android apps
Difference between Kivy and Java for android apps
For a python developer that has some experience creating android apps with
java. I want to create a small app that access my university portal and
retrieve some data to easy access it on android.
1) Which one its easier and faster to develop android apps?
2) Does Kivy has limitations to access certain parts of android (like not
fully integrated with its api)?
3) And finally, an android app developed using kivy would run as fast as
one developed using java?
For a python developer that has some experience creating android apps with
java. I want to create a small app that access my university portal and
retrieve some data to easy access it on android.
1) Which one its easier and faster to develop android apps?
2) Does Kivy has limitations to access certain parts of android (like not
fully integrated with its api)?
3) And finally, an android app developed using kivy would run as fast as
one developed using java?
I'm a super newb: Where to enter code?
I'm a super newb: Where to enter code?
I've been teaching myself how to code. Now, I want to practice my newfound
coding skills by creating a very, very simple web app. What programs do I
need to actually write and test my code and eventually release the app?
I've been searching around the Internet and keep hearing all this random
stuff about integrating my HTML, CSS, and Javascript code then entering
this or that PHP code to communicate with my MySQL database, etc., etc.,
blah^3. And that's all fine to know...but WHERE does all this code go?
Where am I actually typing all this stuff to then preview it and
eventually release my app?
Please let me know if my question doesn't make sense!
I've been teaching myself how to code. Now, I want to practice my newfound
coding skills by creating a very, very simple web app. What programs do I
need to actually write and test my code and eventually release the app?
I've been searching around the Internet and keep hearing all this random
stuff about integrating my HTML, CSS, and Javascript code then entering
this or that PHP code to communicate with my MySQL database, etc., etc.,
blah^3. And that's all fine to know...but WHERE does all this code go?
Where am I actually typing all this stuff to then preview it and
eventually release my app?
Please let me know if my question doesn't make sense!
Subscribe to:
Comments (Atom)