Unable to create Session in Quickblox in Android - android

I am new to Quickblox. I am trying to work on webrtc. I followed the tutorial here. I have also referred to QuickBlox Error with Custom Object (Android). I am getting the following errors when I try to create a session:
Authentication error: Unable to respond to any of these challenges: {}
D/QBASDK(31816): STATUS : 401
D/QBASDK(31816): '{"errors":["Unauthorized"]}'
My full code is pasted below:
public class MainActivity extends ActionBarActivity implements OnClickListener,
QBRTCClientSessionCallbacks, QBRTCClientConnectionCallbacks,
QBRTCClientVideoTracksCallbacks {
QBChatService chatService;
QBUser user1, user2;
QBGLVideoView localVideoVidew;
Button btn_session;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_session = (Button) findViewById(R.id.btn_session);
btn_session.setOnClickListener(MainActivity.this);
/*
* user1 = new User(1, "User1", "user1", "1234", 1); user2 = new User(2,
* "User2", "user2", "1234", 2);
*/
if (!QBChatService.isInitialized()) {
QBChatService.init(MainActivity.this);
chatService.getInstance();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_session:
create_session();
// create_SignallingManager();
break;
default:
break;
}
}
public void create_SignallingManager() {
// TODO Auto-generated method stub
QBChatService
.getInstance()
.getVideoChatWebRTCSignalingManager()
.addSignalingManagerListener(
new QBVideoChatSignalingManagerListener() {
#Override
public void signalingCreated(
QBSignaling qbSignaling, boolean arg1) {
// TODO Auto-generated method stub
if (!arg1) {
QBRTCClient.getInstance().addSignaling(
(QBWebRTCSignaling) qbSignaling);
}
}
});
QBRTCClient.getInstance().setCameraErrorHendler(
new VideoCapturerAndroid.CameraErrorHandler() {
#Override
public void onCameraError(final String s) {
MainActivity.this.runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(MainActivity.this, s,
Toast.LENGTH_LONG).show();
}
});
}
});
QBRTCClient.getInstance()
.addSessionCallbacksListener(MainActivity.this);
QBRTCClient.getInstance().addConnectionCallbacksListener(
MainActivity.this);
QBRTCClient.getInstance().addVideoTrackCallbacksListener(
MainActivity.this);
QBRTCClient.getInstance().prepareToProcessCalls(MainActivity.this);
}
private void create_session() {
QBSettings.getInstance().fastConfigInit("XXXX", "XXXXXXX", "XXXXX");//Have put ids properly in code
final QBUser user = new QBUser("user1", "1234");
QBAuth.createSession(user, new QBCallback() {
#Override
public void onComplete(Result arg0, Object arg1) {
// TODO Auto-generated method stub
QBUsers.signIn(user,new QBCallback() {
#Override
public void onComplete(Result arg0, Object arg1) {
// TODO Auto-generated method stub
}
#Override
public void onComplete(Result arg0) {
// TODO Auto-generated method stub
if(arg0.isSuccess())
{
Log.i("working","fine");
}
}
});
}
#Override
public void onComplete(Result arg0) {
// TODO Auto-generated method stub
}
});
}
#Override
public void onLocalVideoTrackReceive(QBRTCSession arg0,
QBRTCVideoTrack videoTrack) {
// TODO Auto-generated method stub
localVideoVidew = (QBGLVideoView) findViewById(R.id.localVideoView);
Log.d("TAG", "localVideoVidew is " + localVideoVidew);
if (localVideoVidew != null) {
videoTrack.addRenderer(new VideoRenderer(new VideoCallBacks(
localVideoVidew, QBGLVideoView.Endpoint.LOCAL)));
localVideoVidew.setVideoTrack(videoTrack,
QBGLVideoView.Endpoint.LOCAL);
Log.d("TAG", "onLocalVideoTrackReceive() is raned");
}
}
#Override
public void onRemoteVideoTrackReceive(QBRTCSession arg0,
QBRTCVideoTrack arg1, Integer arg2) {
// TODO Auto-generated method stub
}
#Override
public void onConnectedToUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onConnectionClosedForUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onConnectionFailedWithUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onDisconnectedFromUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onDisconnectedTimeoutFromUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onError(QBRTCSession arg0, QBRTCException arg1) {
// TODO Auto-generated method stub
}
#Override
public void onStartConnectToUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onCallRejectByUser(QBRTCSession arg0, Integer arg1,
Map<String, String> arg2) {
// TODO Auto-generated method stub
}
#Override
public void onReceiveHangUpFromUser(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
#Override
public void onReceiveNewSession(QBRTCSession arg0) {
// TODO Auto-generated method stub
}
#Override
public void onSessionClosed(QBRTCSession arg0) {
// TODO Auto-generated method stub
}
#Override
public void onSessionStartClose(QBRTCSession arg0) {
// TODO Auto-generated method stub
}
#Override
public void onUserNotAnswer(QBRTCSession arg0, Integer arg1) {
// TODO Auto-generated method stub
}
}

401 Unauthorized
The request requires user authentication. Basic and Digest Access Authentication"
You are missing onSuccessMethod().
QBSettings.getInstance().fastConfigInit("XXXX", "XXXXXXX", "XXXXX");//Have put ids properly in code
final QBUser user = new QBUser("user1", "1234");
// then the user will be logged in automatically
QBAuth.createSession(login, password, new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession session, Bundle bundle) {
user.setId(session.getUserId());
// INIT CHAT SERVICE
if (!QBChatService.isInitialized()) {
QBChatService.init(this);
chatService = QBChatService.getInstance();
}
// LOG IN CHAT SERVICE
chatService.login(user, new QBEntityCallbackImpl<QBUser>() {
#Override
public void onSuccess() {
// success
}
#Override
public void onError(List errors) {
//error
}
});
}
#Override
public void onError(List<String> errors) {
//error
}
});

Unauthorized means that user's login or password are wrong, you should check this first

Use this method as per notes here
http://quickblox.com/developers/Android#How_to:_add_SDK_to_IDE_and_connect_to_the_cloud
Note there is no "User" field for this create session method
QBAuth.createSession(new QBEntityCallbackImpl() {}

Related

How to tag a page in facebook while posting an image on facebook in android

09-05 13:14:42.500: E/response=0(7474): ==={"error":{"message":"Unsupported post request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100}}
final String inputParm = post_id + "/tags?to=" + "pageId" ;
runOnUiThread(new Runnable() {
public void run() {
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, faceboo.getAccessToken());
Log.e("params TOKEN",""+faceboo.getAccessToken());
mAsyncRunner.request(inputParm, params, "POST", new RequestListener()
{
#Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.e("response=0","==="+response);
}
#Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
Log.e("onIOException","==="+e);
}
#Override
public void onFileNotFoundException(
FileNotFoundException e, Object state) {
// TODO Auto-generated method stub
Log.e("FileNotFoundException","==="+e);
}
#Override
public void onMalformedURLException(
MalformedURLException e, Object state) {
// TODO Auto-generated method stub
Log.e("MalformedURLException","==="+e);
}
#Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
Log.e("FacebookError","==="+e);
}
}, null);
}
});

Unable to play Video in Android LsitView

I have a listView in which
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int pos, long id) {
player.cueVideo("KJ9KzGQq0w");
}
});
private YouTubePlayer player= new YouTubePlayer() {
#Override
public void setShowFullscreenButton(boolean arg0) {
// TODO Auto-generated method stub
}
#Override
public void setPlaylistEventListener(PlaylistEventListener arg0) {
// TODO Auto-generated method stub
}
#Override
public void setPlayerStyle(PlayerStyle arg0) {
// TODO Auto-generated method stub
}
#Override
public void setPlayerStateChangeListener(PlayerStateChangeListener arg0) {
// TODO Auto-generated method stub
}
#Override
public void setPlaybackEventListener(PlaybackEventListener arg0) {
// TODO Auto-generated method stub
}
#Override
public void setOnFullscreenListener(OnFullscreenListener arg0) {
// TODO Auto-generated method stub
}
#Override
public void setManageAudioFocus(boolean arg0) {
// TODO Auto-generated method stub
}
#Override
public void setFullscreenControlFlags(int arg0) {
// TODO Auto-generated method stub
}
#Override
public void setFullscreen(boolean arg0) {
// TODO Auto-generated method stub
}
#Override
public void seekToMillis(int arg0) {
// TODO Auto-generated method stub
}
#Override
public void seekRelativeMillis(int arg0) {
// TODO Auto-generated method stub
}
#Override
public void release() {
// TODO Auto-generated method stub
}
#Override
public void previous() {
// TODO Auto-generated method stub
}
#Override
public void play() {
// TODO Auto-generated method stub
}
#Override
public void pause() {
// TODO Auto-generated method stub
}
#Override
public void next() {
// TODO Auto-generated method stub
}
#Override
public void loadVideos(List<String> arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
#Override
public void loadVideos(List<String> arg0) {
// TODO Auto-generated method stub
}
#Override
public void loadVideo(String arg0, int arg1) {
// TODO Auto-generated method stub
}
#Override
public void loadVideo(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void loadPlaylist(String arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
#Override
public void loadPlaylist(String arg0) {
// TODO Auto-generated method stub
}
#Override
public boolean isPlaying() {
// TODO Auto-generated method stub
return false;
}
#Override
public boolean hasPrevious() {
// TODO Auto-generated method stub
return false;
}
#Override
public boolean hasNext() {
// TODO Auto-generated method stub
return false;
}
#Override
public int getFullscreenControlFlags() {
// TODO Auto-generated method stub
return 0;
}
#Override
public int getDurationMillis() {
// TODO Auto-generated method stub
return 0;
}
#Override
public int getCurrentTimeMillis() {
// TODO Auto-generated method stub
return 0;
}
#Override
public void cueVideos(List<String> arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
#Override
public void cueVideos(List<String> arg0) {
// TODO Auto-generated method stub
}
#Override
public void cueVideo(String arg0, int arg1) {
// TODO Auto-generated method stub
}
#Override
public void cueVideo(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void cuePlaylist(String arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
#Override
public void cuePlaylist(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void addFullscreenControlFlag(int arg0) {
// TODO Auto-generated method stub
}
};
I am using YouTubeAPI for doing this
sample code in API
#Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,boolean wasRestored) {
if (!wasRestored) {
//player.cueVideo("wKJ9KzGQq0w");
}
}
I want to play a video as soon as an element in listView is clicked.
Change your player.cueVideo("wKJ9KzGQq0w"); to player.loadVideo("wKJ9KzGQq0w");.
loadVideo will automatically play when it has finished loading.
Made few changes
#Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player1,boolean wasRestored) {
player=player1;
}
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int pos, long id) {
video_URL="eF9AC2Ce2ow";
video_player.loadVideo(video_URL);
}});

How to keep playing YouTubePlayer in Android

Now I'm creating an Android application witch use YouTube api to play Video.
But the player stop when I change Activity.
I want to keep Playing like a Music Player even when Activity will change.
I try to solve that by adding Static on YouTubePlayer.(But cannot solve.)
I mean I want to Keep it's playing when the Activity or the Application itself move to Background.
So if you have any ideas, please share with me :)
-----------------Code-----------------
public class PlayActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener,YouTubePlayer.PlayerStateChangeListener{
public static final String DEVELOPER_KEY = "My_Dev_Key";
private LinearLayout yPos;
private static YouTubePlayer yt;
private YouTubePlayerView ytp;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play);
yPos = (LinearLayout)findViewById(R.id.youtube_pos);
try{
ytp = new YouTubePlayerView(this);
ytp.initialize(DEVELOPER_KEY, this);
}catch(Exception e){
finish();
}
yPos.addView(ytp);
}
#Override
public void onAdStarted() {
// TODO Auto-generated method stub
}
#Override
public void onError(ErrorReason arg0) {
// TODO Auto-generated method stub
}
#Override
public void onLoaded(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void onLoading() {
// TODO Auto-generated method stub
}
#Override
public void onVideoEnded() {
// TODO Auto-generated method stub
}
#Override
public void onVideoStarted() {
// TODO Auto-generated method stub
}
#Override
public void onInitializationFailure(Provider arg0,
YouTubeInitializationResult arg1) {
// TODO Auto-generated method stub
}
#Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1,
boolean arg2) {
// TODO Auto-generated method stub
if(!arg2){
if(yt == null){
yt = arg1;
yt.setPlayerStateChangeListener(this);
yt.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
yt.loadVideo("u0v5A6cQOhs");
}
}
}
}

Does twitter4j provide event listener for incoming direct messages?

I am developing an application which interacts with Twitter using twitter4j API. Does this API provide an event listener for incomning direct messages?
Please find the implementation in the following code.
Please add the twitter4j-core-2.2.6.jar & twitter4j-stream-2.2.6.jar to your build path.
package com.apt.java.test.twitterdemo;
import java.util.List;
import twitter4j.DirectMessage;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
import twitter4j.User;
import twitter4j.UserList;
import twitter4j.UserStreamListener;
import twitter4j.auth.AccessToken;
import twitter4j.conf.ConfigurationBuilder;
public class TwitterDemo {
private TwitterStream twitterStream;
private void initConfiguration(){
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("YOUR CONSUMER KEY")
.setOAuthConsumerSecret("YOUR CONSUMER SECRET");
TwitterStreamFactory twitterStreamFactory = new TwitterStreamFactory(cb.build());
twitterStream = twitterStreamFactory.getInstance(new AccessToken("YOUR ACCESS TOKEN", "YOUR ACCESS TOKEN SECRET"));
twitterStream.addListener(userStreamListener);
twitterStream.user();
}
UserStreamListener userStreamListener = new UserStreamListener() {
#Override
public void onException(Exception arg0) {
// TODO Auto-generated method stub
}
#Override
public void onTrackLimitationNotice(int arg0) {
// TODO Auto-generated method stub
}
#Override
public void onStatus(Status status) {
// TODO Auto-generated method stub
System.out.println(status.getText());
}
#Override
public void onScrubGeo(long arg0, long arg1) {
// TODO Auto-generated method stub
}
#Override
public void onDeletionNotice(StatusDeletionNotice arg0) {
// TODO Auto-generated method stub
}
#Override
public void onUserProfileUpdate(User arg0) {
// TODO Auto-generated method stub
}
#Override
public void onUserListUpdate(User arg0, UserList arg1) {
// TODO Auto-generated method stub
}
#Override
public void onUserListUnsubscription(User arg0, User arg1, UserList arg2) {
// TODO Auto-generated method stub
}
#Override
public void onUserListSubscription(User arg0, User arg1, UserList arg2) {
// TODO Auto-generated method stub
}
#Override
public void onUserListMemberDeletion(User arg0, User arg1, UserList arg2) {
// TODO Auto-generated method stub
}
#Override
public void onUserListMemberAddition(User arg0, User arg1, UserList arg2) {
// TODO Auto-generated method stub
}
#Override
public void onUserListDeletion(User arg0, UserList arg1) {
// TODO Auto-generated method stub
}
#Override
public void onUserListCreation(User arg0, UserList arg1) {
// TODO Auto-generated method stub
}
#Override
public void onUnfavorite(User arg0, User arg1, Status arg2) {
// TODO Auto-generated method stub
}
#Override
public void onUnblock(User arg0, User arg1) {
// TODO Auto-generated method stub
}
#Override
public void onRetweet(User arg0, User arg1, Status arg2) {
// TODO Auto-generated method stub
}
#Override
public void onFriendList(long[] arg0) {
// TODO Auto-generated method stub
}
#Override
public void onFollow(User arg0, User arg1) {
// TODO Auto-generated method stub
}
#Override
public void onFavorite(User arg0, User arg1, Status arg2) {
// TODO Auto-generated method stub
}
#Override
public void onDirectMessage(DirectMessage message) {
// TODO Auto-generated method stub
System.out.println(message.getText());
}
#Override
public void onDeletionNotice(long arg0, long arg1) {
// TODO Auto-generated method stub
}
#Override
public void onBlock(User arg0, User arg1) {
// TODO Auto-generated method stub
}
};
public static void main(String[] args){
TwitterDemo demo = new TwitterDemo();
demo.initConfiguration();
}
}

Android: adding text color,background and font size to optionsmenu

I tried a lot to add the font size,text color and background for my options menu but couldn't able to solve, how to do this for the following code?Help is always appreciated.....!, Thanks.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add("Share In Heart Club!");
menu.add("Play");
menu.add("Check Your Heart Type?");
menu.add("Cancel");
// Return true so that the menu gets displayed.
return true;
}
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
// Close the menu after a period of time.
// Note that this STARTS the timer when the options menu is being
// prepared, NOT when the menu is made visible.
Timer timing = new Timer();
timing.schedule(new TimerTask() {
#Override
public void run() {
closeOptionsMenu();
}
}, 10000);
return super.onPrepareOptionsMenu(menu);
}
Try the following code
#Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
// MenuInflater inflater = getMenuInflater();
// inflater.inflate(R.menu.menu, menu);
// setContentView(R.layout.menu);
menu.clear();
setMenuBackground();
menu.add(0, MobilePagesConstant.MenuConstant.MENU_ABOUT, 0,
R.string.menu_about).setIcon(R.drawable.ico_about);
menu.add(0, MobilePagesConstant.MenuConstant.MENU_INDEX, 1,
R.string.menu_index).setIcon(R.drawable.ico_help);
// if (HNHConstant.IS_LAST_LIST_ON == 1) {
menu.add(0, MobilePagesConstant.MenuConstant.MENU_CUSTOMER_SUPPORT, 2,
R.string.menu_customer_support).setIcon(
R.drawable.ico_customer_support);
menu.add(0, MobilePagesConstant.MenuConstant.MENU_LEGAL, 3,
R.string.menu_legal).setIcon(R.drawable.ico_moderate);
menu.add(0, MobilePagesConstant.MenuConstant.MENU_GETTING_STARTED, 0,
R.string.menu_getting_started).setIcon(
R.drawable.ico_gettingstarted);
return true;
}
private void setMenuBackground() {
// TODO Auto-generated method stub
getLayoutInflater().setFactory(new Factory() {
#Override
public View onCreateView(final String name, final Context context,
final AttributeSet attrs) {
if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {
try { // Ask our inflater to create the view
final LayoutInflater f = getLayoutInflater();
final View[] view = new View[1];
try {
view[0] = f.createView(name, null, attrs);
} catch (InflateException e) {
chaneDeafultMenu(name, attrs, f, view);
}
// Kind of apply our own background
new Handler().post(new Runnable() {
#Override
public void run() {
view[0].setBackgroundResource(R.drawable.background);
((TextView) view[0]).setTextColor(Color.BLACK);
((TextView) view[0])
.setTypeface(Typeface.SANS_SERIF);
}
});
return view[0];
} catch (InflateException e) {
} catch (ClassNotFoundException e) {
}
}
return null;
}
});
}
static void chaneDeafultMenu(final String name,
final android.util.AttributeSet attrs, final LayoutInflater f,
final View[] view) {
// mConstructorArgs[0] is only non-null during a running call to
// inflate()
// so we make a call to inflate() and inside that call our dully
// XmlPullParser get's called
// and inside that it will work to call
// "f.createView( name, null, attrs );"!
try {
f.inflate(new XmlPullParser() {
#Override
public int next() throws XmlPullParserException, IOException {
try {
view[0] = f.createView(name, null, attrs);
} catch (InflateException e) {
} catch (ClassNotFoundException e) {
}
throw new XmlPullParserException("exit");
}
#Override
public void defineEntityReplacementText(String arg0, String arg1)
throws XmlPullParserException {
// TODO Auto-generated method stub
}
#Override
public int getAttributeCount() {
// TODO Auto-generated method stub
return 0;
}
#Override
public String getAttributeName(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getAttributeNamespace(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getAttributePrefix(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getAttributeType(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getAttributeValue(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getAttributeValue(String arg0, String arg1) {
// TODO Auto-generated method stub
return null;
}
#Override
public int getColumnNumber() {
// TODO Auto-generated method stub
return 0;
}
#Override
public int getDepth() {
// TODO Auto-generated method stub
return 0;
}
#Override
public int getEventType() throws XmlPullParserException {
// TODO Auto-generated method stub
return 0;
}
#Override
public boolean getFeature(String arg0) {
// TODO Auto-generated method stub
return false;
}
#Override
public String getInputEncoding() {
// TODO Auto-generated method stub
return null;
}
#Override
public int getLineNumber() {
// TODO Auto-generated method stub
return 0;
}
#Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
#Override
public String getNamespace() {
// TODO Auto-generated method stub
return null;
}
#Override
public String getNamespace(String arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public int getNamespaceCount(int arg0)
throws XmlPullParserException {
// TODO Auto-generated method stub
return 0;
}
#Override
public String getNamespacePrefix(int arg0)
throws XmlPullParserException {
// TODO Auto-generated method stub
return null;
}
#Override
public String getNamespaceUri(int arg0)
throws XmlPullParserException {
// TODO Auto-generated method stub
return null;
}
#Override
public String getPositionDescription() {
// TODO Auto-generated method stub
return null;
}
#Override
public String getPrefix() {
// TODO Auto-generated method stub
return null;
}
#Override
public Object getProperty(String arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public String getText() {
// TODO Auto-generated method stub
return null;
}
#Override
public char[] getTextCharacters(int[] arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public boolean isAttributeDefault(int arg0) {
// TODO Auto-generated method stub
return false;
}
#Override
public boolean isEmptyElementTag()
throws XmlPullParserException {
// TODO Auto-generated method stub
return false;
}
#Override
public boolean isWhitespace() throws XmlPullParserException {
// TODO Auto-generated method stub
return false;
}
#Override
public int nextTag() throws XmlPullParserException, IOException {
// TODO Auto-generated method stub
return 0;
}
#Override
public String nextText() throws XmlPullParserException,
IOException {
// TODO Auto-generated method stub
return null;
}
#Override
public int nextToken() throws XmlPullParserException,
IOException {
// TODO Auto-generated method stub
return 0;
}
#Override
public void require(int arg0, String arg1, String arg2)
throws XmlPullParserException, IOException {
// TODO Auto-generated method stub
}
#Override
public void setFeature(String arg0, boolean arg1)
throws XmlPullParserException {
// TODO Auto-generated method stub
}
#Override
public void setInput(Reader arg0) throws XmlPullParserException {
// TODO Auto-generated method stub
}
#Override
public void setInput(InputStream arg0, String arg1)
throws XmlPullParserException {
// TODO Auto-generated method stub
}
#Override
public void setProperty(String arg0, Object arg1)
throws XmlPullParserException {
// TODO Auto-generated method stub
}
}, null, false);
} catch (InflateException e1) {
// "exit" ignored
}
}
http://www.droidnova.com/how-to-create-an-option-menu,427.html
Please check the link and vote up if u find it useful
Applying styles / themes to the options menu is not easy in Android. However, there is a great article which shows you how to implement your own.
Setting the background colour is possible, but it's quite buggy on 2.3. See How to change the background color of the options menu? for more information.
Create a custom xml view with your fav icons and colors. Use menuinflator to inflate them to options menu.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.splash_screen, menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.payby_menu, menu);
getLayoutInflater().setFactory(new Factory() {
#Override
public View onCreateView(String name, Context context,
AttributeSet attrs) {
if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {
try {
LayoutInflater f = getLayoutInflater();
final View view = f.createView(name, null, attrs);
new Handler().post(new Runnable() {
public void run() {
// set the background drawable
// view.setBackgroundResource(R.drawable.my_ac_menu_background);
// set the text color
((TextView) view).setTextColor(Color.WHITE);
}
});
return view;
} catch (InflateException e) {
} catch (ClassNotFoundException e) {
}
}
return null;
}
});
return super.onCreateOptionsMenu(menu);
}
1: you can simply add color to text by just writing
android:textColor="#ff00ff"
in your layout xml in textview tag
or second method is
you can add color by using
values->string.xml and adding a color resource to your string

Categories

Resources