|
First tell us, where did you even the get the source code, and how is it Android Studio project?
Typically, most of the projects come with a directory structure, that lets your IDE easily pick up, Android Studio is smart enough to do that, secondly you can easily read the methods from the location where you downloaded the project from.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
From the main screen, use the Import project (Eclipse ADT, Gradle, etc.) option.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hello ,
I hv tried to add itext library to the dependency , if I type itex in the search am told there is nothing to show.
Thanks .
|
|
|
|
|
|
Member 13229874 wrote: ...add itext library to the dependency... Of what? Eclipse, Android Studio, or some other IDE?
Member 13229874 wrote: if I type itex in the search... In what?
Member 13229874 wrote: ...there is nothing to show. What should be shown?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
It's been a while since I've participated on CP, and I'm back with a doozy
I'm having a problem with MediaExtractor and using a MemoryFile as the data source. In the real world, this media viewer is part of a larger app that supplies a chunk of bytes that contains a complete MP4 video. To eliminate all the other stuff, I have created a little demo app that only contains the viewer and a test MemoryFile. Please note that not using a MemoryFile, i.e. saving the video data to storage and playing from there, is not an option.
First, the code. I create the MemoryFile in the test app's MainActivity.onCreate
InputStream inS = getResources ().getAssets ().open ("testmp4.mp4");
int length = inS.available ();
byte[] data = new byte[length];
inS.read (data);
inS.close ();
m_memFile = new MemoryFile (null, length);
m_memFile.writeBytes (data, 0, 0, length);
Method getFD = MemoryFile.class.getMethod ("getFileDescriptor");
m_memFileFD = (FileDescriptor) getFD.invoke (m_memFile);
This is in the MainActivity's Play button click listener:
if (m_player == null)
{
m_player = new MyPlayer (MainActivity.this.m_events, MainActivity.this.m_memFileFD, MainActivity.this.m_memFile.length (), (SurfaceView) findViewById (R.id.viewerMediaVideo));
}
m_player.play ();
The video player is in the class MyPlayer that extends Runnable:
protected MediaExtractor m_extractor = null;
protected PlayerStates m_state = PlayerStates.STOPPED;
private SurfaceHolder m_surface = null;
protected FileDescriptor m_memFileFD = null;
protected long m_memFileLen = 0;
public MyPlayer (PlayerEvents ev, FileDescriptor fd, long len, SurfaceView s)
{
m_events = ev;
m_memFileFD = fd;
m_memFileLen = len;
m_surface = s.getHolder ();
}
public void play ()
{
if (m_state == PlayerStates.STOPPED)
{
m_stop = false;
new Thread (this).start ();
}
...
}
public void run ()
{
android.os.Process.setThreadPriority (Process.THREAD_PRIORITY_URGENT_AUDIO);
m_extractor = new MediaExtractor ();
try
{
m_extractor.setDataSource (m_memFileFD, 0, m_memFileLen);
}
catch (final Exception excp)
{
m_extractor.release ();
m_extractor = null;
m_handler.post (new Runnable (){public void run ()
{m_events.onError ("can't create extractor: " + excp.getMessage ()); } });
return;
}
....
}
Now for the problem. I have tested the same APK on different devices, both actual physical phones and emulators and the results are:
S5 with 4.4.2 / API:19 emulator --> works
M9 with 5.0.2 / API:21 emulator / API:22 emulator --> works
Nexus6 with 6.0 / API:23 emulator --> works
S7 with 6.0.1 / (no emulator for this point release) --> fails
Nexus6 with 7.0 / API:24 emulator --> fails
works means the video plays correctly
fails means I get the error "can't create extractor: Failed to instantiate extractor". This is the catch at the very beginning of the player's run method
6.0.1 logcat shows thirteen lines like (only varying between the digit 0 and 4):
FileSource: seek to 0 failed
7.0 / API:24 emulator logcat contains a single line:
FileSource: offset/length adjusted from 0/547251 to 0/0
I've tried two versions of the app on the physical devices. One has a minimumSDK set to 19 and the targetSDK / compileSDK / build tools are version 21. The second version has minSDK 19 and the rest 23. The version running on the emulators has minSDK19, targetSDK 23, and compileSDK/ buildTools 25 -- the latest that I just downloaded yesterday. All three different builds of the same code fail in the same pattern based on OS version.
This points me to a change between OS versions 6.0 and 6.0.1 causing the issue. However, I've done some poking into the sources available on the net and don't see anything suspicious.
Any ideas? Do I need to go report a bug to Google?
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
Just a followup ... I never did get around to harassing Google about this. I simply worked around the problem by checking the build version and only using the "old" way with a MemoryFile for KitKat and Lollipop and using the "new with API 23" MediaDataSource with the data behind the MemoryFile for Marshmallow and up.
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
I have created android chat application. When I send message it loops all messages through notification and then show the latest message instead of just showing newest message inside the notification!!!! How to fix this issue???
public class Chat extends AppCompatActivity
{
LinearLayout layout;
RelativeLayout layout_2;
ImageView sendButton;
EditText messageArea;
ScrollView scrollView;
Firebase reference1, reference2;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
layout = (LinearLayout) findViewById(R.id.layout1);
layout_2 = (RelativeLayout)findViewById(R.id.layout2);
sendButton = (ImageView)findViewById(R.id.sendButton);
messageArea = (EditText)findViewById(R.id.messageArea);
scrollView = (ScrollView)findViewById(R.id.scrollView);
Firebase.setAndroidContext(this);
reference1 = new Firebase("https://zipa1x.firebaseio.com/messages/" + UserDetails.username + "_" + UserDetails.chatWith);
reference2 = new Firebase("https://zipa1x.firebaseio.com/messages/" + UserDetails.chatWith + "_" + UserDetails.username);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String messageText = messageArea.getText().toString();
if(!messageText.equals("")){
Map<String, String> map = new HashMap<String, String>();
map.put("message", messageText);
map.put("user", UserDetails.username);
reference1.push().setValue(map);
reference2.push().setValue(map);
messageArea.setText("");
}
}
});
reference1.addChildEventListener(new ChildEventListener()
{
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
for (DataSnapshot child: dataSnapshot.getChildren())
{
Map map = dataSnapshot.getValue(Map.class);
String message = map.get("message").toString();
String userName = map.get("user").toString();
if (userName.equals(UserDetails.username))
{
addMessageBox("You:-\n" + message, 1);
} else
{
addMessageBox(UserDetails.chatWith + ":-\n" + message, 2);
sendNotification(message,userName);
}
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
}
public void addMessageBox(String message, int type){
TextView textView = new TextView(Chat.this);
textView.setText(message);
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp2.weight = 1.0f;
if(type == 1) {
lp2.gravity = Gravity.LEFT;
textView.setBackgroundResource(R.drawable.bubble_in);
}
else{
lp2.gravity = Gravity.RIGHT;
textView.setBackgroundResource(R.drawable.bubble_out);
}
textView.setLayoutParams(lp2);
layout.addView(textView);
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
}
private void sendNotification(String message,String userName)
{
Intent intent = new Intent(this,Chat.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(userName)
.setContentText(message)
.setSound(notificationSound)
.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(0, builder.build());
}
}
|
|
|
|
|
Please provide some proper details, and explain exactly where the error occurs.
|
|
|
|
|
I would like to create an android app that will predict football result..i am planning to use neural networks behind to work in the app...how can i go about it..the difficult side is to apply the algorithm...am i going to code it or what should i do..
|
|
|
|
|
Member 13208523 wrote: .how can i go about it By starting.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
i dont understand what you are trying to mean
|
|
|
|
|
Member 13208523 wrote: am i going to code it Well that would be a good start.
|
|
|
|
|
I am trying to create an app to get location and make it location change aware.
|
|
|
|
|
You can use the Location APIs in Android, that are supported in Java language. You can utilize it to consume the location services from GSM or GPS based location services.
I wrote an article that covers the basics of this concept; Ok Android, Broadcast my location!
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
See here, and here (preferred).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I used jdbc ("net.sourceforge.jtds.jdbc.Driver" -jtds-1.3.1.jar)for My Android Application:
String ip = "192.168.3.67";
String classs = "net.sourceforge.jtds.jdbc.Driver";
String db = "QLNV";
String un = "sa";
String password = "admin";
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = null;
String ConnURL = null;
try {
Class.forName(classs);
ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
+ "databaseName=" + db + ";user=" + un + ";password="
+ password + ";";
conn = DriverManager.getConnection(ConnURL);...
I tested it on Android Emulator: it worked well but I tested it on my Android phone: it maybe not worked well. I don't know why? please help me, thanks much..
|
|
|
|
|
Your phone is probably not on your local 192.168.xxx.xxx LAN.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
So..How can i do? I added :
<uses-permission android:name="android.permission.INTERNET">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
in AndroidManifest.xml
So can help me? thanhs a lot!
|
|
|
|
|
Before worrying about permissions, I'd make sure the phone is connected to your LAN through wifi. The phone should show your network name and "Connected" at the top of the wifi list under settings. Until you get that set up, you have no hope of accessing your server.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Member 11900140 wrote: on my Android phone: it maybe not worked well. You need to explain what that means, we cannot guess what failures or errors you see.
|
|
|
|
|
My Real Android phone: can not connect to or get data from my Sql Server database QLNS.
|
|
|
|
|
Why not? Does it have a network connection to the database server?
|
|
|
|
|
Are you checking for errors? Are exceptions being thrown? Have you stepped through the code using the debugger?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Don't be silly. Who does that when CodeProject is here?
|
|
|
|